Skip to content

Commit

Permalink
TF-3396 Fix mobile app can not get the latest email when open app fro…
Browse files Browse the repository at this point in the history
…m terminated
  • Loading branch information
dab246 authored and hoangdat committed Jan 7, 2025
1 parent 57a22b9 commit 9ceb56c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ class MailboxDashBoardController extends ReloadableController
StreamSubscription? _pendingSharedFileInfoSubscription;
StreamSubscription? _receivingFileSharingStreamSubscription;
StreamSubscription? _currentEmailIdInNotificationIOSStreamSubscription;
bool _isFirstSessionLoad = false;

final StreamController<Either<Failure, Success>> _progressStateController =
StreamController<Either<Failure, Success>>.broadcast();
Expand All @@ -264,6 +265,10 @@ class MailboxDashBoardController extends ReloadableController
final _notificationManager = LocalNotificationManager.instance;
final _fcmService = FcmService.instance;

bool get isFirstSessionLoad => _isFirstSessionLoad;

bool setIsFirstSessionLoad(bool value) => _isFirstSessionLoad = value;

MailboxDashBoardController(
this._moveToMailboxInteractor,
this._deleteEmailPermanentlyInteractor,
Expand Down Expand Up @@ -645,6 +650,7 @@ class MailboxDashBoardController extends ReloadableController

void _setUpComponentsFromSession(Session session) {
final currentAccountId = session.accountId;
_isFirstSessionLoad = true;
sessionCurrent = session;
accountId.value = currentAccountId;

Expand Down Expand Up @@ -3140,6 +3146,7 @@ class MailboxDashBoardController extends ReloadableController
mapDefaultMailboxIdByRole = {};
WebSocketController.instance.onClose();
_currentEmailState = null;
_isFirstSessionLoad = false;
super.onClose();
}
}
7 changes: 5 additions & 2 deletions lib/features/thread/presentation/thread_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ class ThreadController extends BaseController with EmailActionController {
_currentMemoryMailboxId = mailbox.id;
consumeState(Stream.value(Right(GetAllEmailLoading())));
_resetToOriginalValue();
_getAllEmailAction(getLatestChanges: false);
_getAllEmailAction(
getLatestChanges: mailboxDashBoardController.isFirstSessionLoad,
);
mailboxDashBoardController.setIsFirstSessionLoad(false);
} else if (mailbox == null) { // disable current mailbox when search active
_currentMemoryMailboxId = null;
_resetToOriginalValue();
Expand Down Expand Up @@ -520,7 +523,7 @@ class ThreadController extends BaseController with EmailActionController {
void _getAllEmailAction({
bool getLatestChanges = true,
}) {
log('ThreadController::_getAllEmailAction:');
log('ThreadController::_getAllEmailAction:getLatestChanges = $getLatestChanges');
if (_session != null &&_accountId != null) {
consumeState(_getEmailsInMailboxInteractor.execute(
_session!,
Expand Down

0 comments on commit 9ceb56c

Please sign in to comment.