Skip to content

Commit 25b6e8b

Browse files
committed
TF-4186 Automatically jump to login when open app from terminated
1 parent 77757a6 commit 25b6e8b

File tree

5 files changed

+51
-23
lines changed

5 files changed

+51
-23
lines changed

lib/features/base/base_controller.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,15 +399,15 @@ abstract class BaseController extends GetxController
399399

400400
void goToLogin() {
401401
if (PlatformInfo.isMobile) {
402-
navigateToTwakeWelcomePage();
402+
getCompanyServerLoginInfo(popAllRoute: false);
403403
} else {
404404
navigateToLoginPage();
405405
}
406406
}
407407

408408
void removeAllPageAndGoToLogin() {
409409
if (PlatformInfo.isMobile) {
410-
getCompanyServerLoginInfo();
410+
getCompanyServerLoginInfo(popAllRoute: true);
411411
} else {
412412
navigateToLoginPage();
413413
}

lib/features/base/extensions/handle_company_server_login_info_extension.dart

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,33 @@ import 'package:tmail_ui_user/main/routes/app_routes.dart';
77
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
88

99
extension HandleCompanyServerLoginInfoExtension on BaseController {
10-
void getCompanyServerLoginInfo() async {
11-
consumeState(getCompanyServerLoginInfoInteractor.execute());
10+
void getCompanyServerLoginInfo({bool popAllRoute = true}) async {
11+
consumeState(
12+
getCompanyServerLoginInfoInteractor.execute(popAllRoute: popAllRoute),
13+
);
1214
}
1315

14-
void handleGetCompanyServerLoginInfoSuccess(CompanyServerLoginInfo info) {
15-
log('$runtimeType::handleGetCompanyServerLoginInfoSuccess: Info = $info');
16-
pushAndPopAll(
17-
AppRoutes.login,
18-
arguments: LoginArguments(
19-
LoginFormType.dnsLookupForm,
20-
loginInfo: info,
21-
)
16+
void handleGetCompanyServerLoginInfoSuccess(
17+
CompanyServerLoginInfo info, {
18+
bool popAllRoute = true,
19+
}) {
20+
log('$runtimeType::handleGetCompanyServerLoginInfoSuccess: Info = $info, popAllRoute = $popAllRoute');
21+
final arguments = LoginArguments(
22+
LoginFormType.dnsLookupForm,
23+
loginInfo: info,
2224
);
25+
if (popAllRoute) {
26+
pushAndPopAll(AppRoutes.login, arguments: arguments);
27+
} else {
28+
popAndPush(AppRoutes.login, arguments: arguments);
29+
}
2330
}
2431

25-
void handleGetCompanyServerLoginInfoFailure() {
26-
pushAndPopAll(AppRoutes.twakeWelcome);
32+
void handleGetCompanyServerLoginInfoFailure({bool popAllRoute = true}) {
33+
if (popAllRoute) {
34+
pushAndPopAll(AppRoutes.twakeWelcome);
35+
} else {
36+
popAndPush(AppRoutes.twakeWelcome);
37+
}
2738
}
2839
}

lib/features/login/domain/state/get_company_server_login_info_state.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@ class GettingCompanyServerLoginInfo extends LoadingState {}
66

77
class GetCompanyServerLoginInfoSuccess extends UIState {
88
final CompanyServerLoginInfo serverLoginInfo;
9+
final bool popAllRoute;
910

10-
GetCompanyServerLoginInfoSuccess(this.serverLoginInfo);
11+
GetCompanyServerLoginInfoSuccess(
12+
this.serverLoginInfo, {
13+
this.popAllRoute = true,
14+
});
1115

1216
@override
13-
List<Object> get props => [serverLoginInfo];
17+
List<Object> get props => [serverLoginInfo, popAllRoute];
1418
}
1519

1620
class GetCompanyServerLoginInfoFailure extends FeatureFailure {
17-
GetCompanyServerLoginInfoFailure(dynamic exception)
18-
: super(exception: exception);
21+
final bool popAllRoute;
22+
23+
GetCompanyServerLoginInfoFailure(
24+
dynamic exception, {
25+
this.popAllRoute = true,
26+
}) : super(exception: exception);
27+
28+
@override
29+
List<Object> get props => [exception, popAllRoute];
1930
}

lib/features/login/domain/usecases/get_company_server_login_info_interactor.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@ class GetCompanyServerLoginInfoInteractor {
1111

1212
GetCompanyServerLoginInfoInteractor(this._serverLoginRepository);
1313

14-
Stream<Either<Failure, Success>> execute() async* {
14+
Stream<Either<Failure, Success>> execute({bool popAllRoute = true}) async* {
1515
try {
1616
yield Right(GettingCompanyServerLoginInfo());
1717
final serverLoginInfo =
1818
await _serverLoginRepository.getCompanyServerLoginInfo();
19-
yield Right(GetCompanyServerLoginInfoSuccess(serverLoginInfo));
19+
yield Right(GetCompanyServerLoginInfoSuccess(
20+
serverLoginInfo,
21+
popAllRoute: popAllRoute,
22+
));
2023
} catch (exception) {
21-
yield Left(GetCompanyServerLoginInfoFailure(exception));
24+
yield Left(GetCompanyServerLoginInfoFailure(
25+
exception,
26+
popAllRoute: popAllRoute,
27+
));
2228
}
2329
}
2430
}

test/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void main() {
264264
final deleteCredentialInteractor = MockDeleteCredentialInteractor();
265265
final logoutOidcInteractor = MockLogoutOidcInteractor();
266266
final deleteAuthorityOidcInteractor = MockDeleteAuthorityOidcInteractor();
267-
final detCompanyServerLoginInfoInteractor = MockGetCompanyServerLoginInfoInteractor();
267+
final getCompanyServerLoginInfoInteractor = MockGetCompanyServerLoginInfoInteractor();
268268
final appToast = MockAppToast();
269269
final imagePaths = MockImagePaths();
270270
final responsiveUtils = MockResponsiveUtils();
@@ -341,7 +341,7 @@ void main() {
341341
Get.put<DeleteCredentialInteractor>(deleteCredentialInteractor);
342342
Get.put<LogoutOidcInteractor>(logoutOidcInteractor);
343343
Get.put<DeleteAuthorityOidcInteractor>(deleteAuthorityOidcInteractor);
344-
Get.put<GetCompanyServerLoginInfoInteractor>(detCompanyServerLoginInfoInteractor);
344+
Get.put<GetCompanyServerLoginInfoInteractor>(getCompanyServerLoginInfoInteractor);
345345
Get.put<AppToast>(appToast);
346346
Get.put<ImagePaths>(imagePaths);
347347
Get.put<ResponsiveUtils>(responsiveUtils);

0 commit comments

Comments
 (0)