TF-1360 Fix open again email detailed when logout app opened from notification
This commit is contained in:
+7
-6
@@ -371,8 +371,8 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
}
|
||||
|
||||
void _handleClickLocalNotificationOnTerminated() async {
|
||||
await _notificationManager.getNotificationDetails();
|
||||
final notificationResponse = _notificationManager.currentNotificationResponse;
|
||||
_notificationManager.activatedNotificationClickedOnTerminate = true;
|
||||
final notificationResponse = await _notificationManager.getCurrentNotificationResponse();
|
||||
log('MailboxDashBoardController::_handleClickLocalNotificationOnTerminated():payload: ${notificationResponse?.payload}');
|
||||
final emailIdFromPayload = notificationResponse?.payload;
|
||||
final currentAccountId = accountId.value;
|
||||
@@ -391,9 +391,6 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
}
|
||||
|
||||
void _getSessionCurrent() {
|
||||
if (BuildUtils.isWeb) {
|
||||
dispatchRoute(DashboardRoutes.thread);
|
||||
}
|
||||
final arguments = Get.arguments;
|
||||
log('MailboxDashBoardController::_getSessionCurrent(): arguments = $arguments');
|
||||
if (arguments is Session) {
|
||||
@@ -406,10 +403,13 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
injectFCMBindings(sessionCurrent, accountId.value);
|
||||
_getVacationResponse();
|
||||
|
||||
if (!BuildUtils.isWeb) {
|
||||
if (!BuildUtils.isWeb && !_notificationManager.isNotificationClickedOnTerminate) {
|
||||
_handleClickLocalNotificationOnTerminated();
|
||||
} else {
|
||||
dispatchRoute(DashboardRoutes.thread);
|
||||
}
|
||||
} else {
|
||||
dispatchRoute(DashboardRoutes.thread);
|
||||
reload();
|
||||
}
|
||||
}
|
||||
@@ -1383,6 +1383,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
}
|
||||
|
||||
void _handleClickLocalNotificationOnForeground(NotificationResponse? response) {
|
||||
_notificationManager.activatedNotificationClickedOnTerminate = true;
|
||||
log('MailboxDashBoardController::_handleClickLocalNotificationOnForeground():payload: ${response?.payload}');
|
||||
final emailIdFromPayload = response?.payload;
|
||||
final currentAccountId = accountId.value;
|
||||
|
||||
+13
-8
@@ -18,7 +18,9 @@ class LocalNotificationManager {
|
||||
static LocalNotificationManager get instance => _instance;
|
||||
|
||||
final _localNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
||||
bool notificationsEnabled = false;
|
||||
|
||||
bool _notificationsEnabled = false;
|
||||
bool _isNotificationClickedOnTerminate = false;
|
||||
|
||||
final StreamController<NotificationResponse> localNotificationsController = StreamController<NotificationResponse>.broadcast();
|
||||
|
||||
@@ -40,16 +42,19 @@ class LocalNotificationManager {
|
||||
return Future.value();
|
||||
}
|
||||
|
||||
Future<void> getNotificationDetails() async {
|
||||
Future<NotificationResponse?> getCurrentNotificationResponse() async {
|
||||
try {
|
||||
_notificationAppLaunchDetails = await _localNotificationsPlugin.getNotificationAppLaunchDetails();
|
||||
return _notificationAppLaunchDetails?.notificationResponse;
|
||||
} catch (e) {
|
||||
logError('LocalNotificationManager::getNotificationDetails(): ERROR: ${e.toString()}');
|
||||
logError('LocalNotificationManager::getCurrentNotificationResponse(): ERROR: ${e.toString()}');
|
||||
}
|
||||
return Future.value();
|
||||
return Future.value(null);
|
||||
}
|
||||
|
||||
NotificationResponse? get currentNotificationResponse => _notificationAppLaunchDetails?.notificationResponse;
|
||||
set activatedNotificationClickedOnTerminate(bool clicked) => _isNotificationClickedOnTerminate = clicked;
|
||||
|
||||
bool get isNotificationClickedOnTerminate => _isNotificationClickedOnTerminate;
|
||||
|
||||
Future<bool?> _initLocalNotification() async {
|
||||
return await _localNotificationsPlugin.initialize(
|
||||
@@ -69,17 +74,17 @@ class LocalNotificationManager {
|
||||
}
|
||||
|
||||
void _checkLocalNotificationPermission() async {
|
||||
if (notificationsEnabled) {
|
||||
if (_notificationsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
final granted = await _isAndroidPermissionGranted();
|
||||
if (!granted) {
|
||||
notificationsEnabled = await _requestPermissions();
|
||||
_notificationsEnabled = await _requestPermissions();
|
||||
}
|
||||
} else {
|
||||
notificationsEnabled = await _requestPermissions();
|
||||
_notificationsEnabled = await _requestPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user