TF-3290 Only show reconnection confirm dialog when composer is opened

This commit is contained in:
dab246
2024-12-12 15:51:03 +07:00
committed by Dat H. Pham
parent 6e59633bf6
commit b83e092e47
19 changed files with 141 additions and 50 deletions
+44 -36
View File
@@ -60,6 +60,7 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart';
import 'package:tmail_ui_user/main/utils/app_config.dart';
import 'package:tmail_ui_user/main/universal_import/html_stub.dart' as html;
import 'package:tmail_ui_user/main/utils/toast_manager.dart';
import 'package:tmail_ui_user/main/utils/twake_app_manager.dart';
import 'package:uuid/uuid.dart';
abstract class BaseController extends GetxController
@@ -81,6 +82,7 @@ abstract class BaseController extends GetxController
final Uuid uuid = Get.find<Uuid>();
final ApplicationManager applicationManager = Get.find<ApplicationManager>();
final ToastManager toastManager = Get.find<ToastManager>();
final TwakeAppManager twakeAppManager = Get.find<TwakeAppManager>();
bool _isFcmEnabled = false;
@@ -218,43 +220,49 @@ abstract class BaseController extends GetxController
}
void _handleBadCredentialsException() {
if (PlatformInfo.isWeb) {
if (currentContext == null) {
_executeBeforeReconnectAndLogOut();
return;
}
showConfirmDialogAction(
currentContext!,
AppLocalizations.of(currentContext!).dialogMessageSessionHasExpired,
AppLocalizations.of(currentContext!).reconnect,
title: AppLocalizations.of(currentContext!).sessionExpired,
alignCenter: true,
outsideDismissible: false,
titleActionButtonMaxLines: 1,
icon: SvgPicture.asset(imagePaths.icTMailLogo, width: 64, height: 64),
onConfirmAction: _executeBeforeReconnectAndLogOut,
onCancelAction: onCancelReconnectWhenSessionExpired
);
} else if (PlatformInfo.isMobile) {
if (currentContext == null) {
clearDataAndGoToLoginPage();
return;
}
showConfirmDialogAction(
currentContext!,
AppLocalizations.of(currentContext!).dialogMessageSessionHasExpired,
AppLocalizations.of(currentContext!).reconnect,
title: AppLocalizations.of(currentContext!).sessionExpired,
alignCenter: true,
outsideDismissible: false,
titleActionButtonMaxLines: 1,
icon: SvgPicture.asset(imagePaths.icTMailLogo, width: 64, height: 64),
onConfirmAction: clearDataAndGoToLoginPage,
onCancelAction: onCancelReconnectWhenSessionExpired
);
log('$runtimeType::_handleBadCredentialsException:');
if (!twakeAppManager.isComposerOpened) {
_performReconnection();
return;
}
if (currentContext == null) {
_performSaveAndReconnection();
return;
}
final appLocalizations = AppLocalizations.of(currentContext!);
showConfirmDialogAction(
currentContext!,
appLocalizations.messageWarningDialogWhenExpiredOIDCTokenAndReconnection,
appLocalizations.saveAndRefresh,
title: appLocalizations.sessionExpired,
cancelTitle: appLocalizations.no,
alignCenter: true,
outsideDismissible: false,
titleActionButtonMaxLines: 1,
marginIcon: EdgeInsetsDirectional.zero,
icon: SvgPicture.asset(imagePaths.icTMailLogo, width: 64, height: 64),
onConfirmAction: _performSaveAndReconnection,
onCancelAction: _performReconnection,
onCloseButtonAction: _performCloseReconnectionConfirmDialog
);
}
void _performSaveAndReconnection() {
if (PlatformInfo.isWeb) {
_executeBeforeReconnectAndLogOut();
} else if (PlatformInfo.isMobile) {
clearDataAndGoToLoginPage();
}
}
void _performReconnection() {
clearDataAndGoToLoginPage();
}
void _performCloseReconnectionConfirmDialog() {
popBack();
}
void onDataFailureViewState(Failure failure) {
@@ -432,6 +432,7 @@ class MailboxDashBoardController extends ReloadableController
} else if (success is GetAllIdentitiesSuccess) {
_handleGetAllIdentitiesSuccess(success);
} else if (success is GetComposerCacheSuccess) {
_removeComposerCacheOnWeb();
goToComposer(ComposerArguments.fromSessionStorageBrowser(success.composerCache));
} else if (success is GetIdentityCacheOnWebSuccess) {
goToSettings();
@@ -1677,12 +1678,14 @@ class MailboxDashBoardController extends ReloadableController
composerArguments = arguments;
ComposerBindings().dependencies();
composerOverlayState.value = ComposerOverlayState.active;
twakeAppManager.openComposerOnWeb();
}
void closeComposerOverlay({dynamic result}) async {
composerArguments = null;
ComposerBindings().dispose();
composerOverlayState.value = ComposerOverlayState.inActive;
twakeAppManager.closeComposerOnWeb();
if (result is SendingEmailArguments) {
handleSendEmailAction(result);
} else if (result is SendEmailSuccess ||
@@ -3240,6 +3243,7 @@ class MailboxDashBoardController extends ReloadableController
WebSocketController.instance.onClose();
_currentEmailState = null;
_isFirstSessionLoad = false;
twakeAppManager.closeComposerOnWeb();
super.onClose();
}
}
+3 -7
View File
@@ -1,5 +1,5 @@
{
"@@last_modified": "2024-12-09T13:59:58.460897",
"@@last_modified": "2024-12-12T15:50:46.911821",
"initializing_data": "Initializing data...",
"@initializing_data": {
"type": "text",
@@ -3968,12 +3968,6 @@
"placeholders_order": [],
"placeholders": {}
},
"dialogMessageSessionHasExpired": "The current session has expired. Please reconnect to the server",
"@dialogMessageSessionHasExpired": {
"type": "text",
"placeholders_order": [],
"placeholders": {}
},
"sMimeGoodSignatureMessage": "The authenticity of this message had been verified with SMime signature.",
"@sMimeGoodSignatureMessage": {
"type": "text",
@@ -4174,6 +4168,8 @@
},
"editAsNewEmail": "Edit as new email",
"@editAsNewEmail": {
"messageWarningDialogWhenExpiredOIDCTokenAndReconnection": "Your session expired. We need to take you back to the login page in order to refresh it. You might want to save the email you are currently editing before we do so.",
"@messageWarningDialogWhenExpiredOIDCTokenAndReconnection": {
"type": "text",
"placeholders_order": [],
"placeholders": {}
+3
View File
@@ -16,6 +16,7 @@ import 'package:tmail_ui_user/main/pages/app_pages.dart';
import 'package:tmail_ui_user/main/routes/app_routes.dart';
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
import 'package:tmail_ui_user/main/utils/app_utils.dart';
import 'package:tmail_ui_user/main/utils/twake_app_manager.dart';
import 'package:url_strategy/url_strategy.dart';
import 'package:worker_manager/worker_manager.dart';
@@ -52,6 +53,7 @@ class TMailApp extends StatefulWidget {
class _TMailAppState extends State<TMailApp> {
DeepLinksManager? _deepLinksManager;
final TwakeAppManager _twakeAppManager = Get.find<TwakeAppManager>();
@override
void initState() {
@@ -105,6 +107,7 @@ class _TMailAppState extends State<TMailApp> {
if (PlatformInfo.isMobile) {
_deepLinksManager?.dispose();
}
_twakeAppManager.dispose();
super.dispose();
}
}
@@ -21,6 +21,7 @@ import 'package:tmail_ui_user/main/utils/app_config.dart';
import 'package:tmail_ui_user/main/utils/email_receive_manager.dart';
import 'package:tmail_ui_user/main/utils/ios_notification_manager.dart';
import 'package:tmail_ui_user/main/utils/toast_manager.dart';
import 'package:tmail_ui_user/main/utils/twake_app_manager.dart';
import 'package:uuid/uuid.dart';
class CoreBindings extends Bindings {
@@ -76,6 +77,7 @@ class CoreBindings extends Bindings {
Get.put(IOSNotificationManager());
}
Get.put(PreviewEmlFileUtils());
Get.put(TwakeAppManager());
}
void _bindingIsolate() {
@@ -4149,13 +4149,6 @@ class AppLocalizations {
);
}
String get dialogMessageSessionHasExpired {
return Intl.message(
'The current session has expired. Please reconnect to the server',
name: 'dialogMessageSessionHasExpired',
);
}
String get sMimeGoodSignatureMessage {
return Intl.message(
'The authenticity of this message had been verified with SMime signature.',
@@ -4343,6 +4336,14 @@ class AppLocalizations {
);
}
String get messageWarningDialogWhenExpiredOIDCTokenAndReconnection {
return Intl.message(
'Your session expired. We need to take you back to the login page in order to refresh it. You might want to save the email you are currently editing before we do so.',
name: 'messageWarningDialogWhenExpiredOIDCTokenAndReconnection',
);
}
String get replyToList {
return Intl.message(
'Reply to list',
+20
View File
@@ -0,0 +1,20 @@
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/composer_overlay_state.dart';
class TwakeAppManager {
ComposerOverlayState? _composerOverlayState;
void openComposerOnWeb() =>
_composerOverlayState = ComposerOverlayState.active;
void closeComposerOnWeb() {
_composerOverlayState = ComposerOverlayState.inActive;
_composerOverlayState = null;
}
bool get isComposerOpened =>
_composerOverlayState == ComposerOverlayState.active;
void dispose() {
_composerOverlayState = null;
}
}