Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TF-3396 Fix mobile app can not get the latest email when open app from terminated #3400

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading