TF-4368 Fix cannot scroll in email list

This commit is contained in:
dab246
2026-03-11 11:55:05 +07:00
committed by Dat H. Pham
parent eecdf75f5e
commit a28d5b3527
2 changed files with 18 additions and 10 deletions
@@ -364,13 +364,8 @@ class ThreadRepositoryImpl extends ThreadRepository {
return EmailsResponse(emailList: response.first, state: response.last); return EmailsResponse(emailList: response.first, state: response.last);
}); });
final currentLimitEmails =
limit?.value ?? ThreadConstants.defaultLimit.value;
log('ThreadRepositoryImpl::refreshChanges: Current limit emails is $currentLimitEmails');
if (!newEmailResponse.hasEmails() if (!newEmailResponse.hasEmails()
|| (newEmailResponse.emailList?.length ?? 0) < currentLimitEmails) { || (newEmailResponse.emailList?.length ?? 0) < ThreadConstants.defaultLimit.value) {
final networkEmailResponse = await _getFirstPage( final networkEmailResponse = await _getFirstPage(
session, session,
accountId, accountId,
@@ -216,7 +216,6 @@ class ThreadController extends BaseController with EmailActionController {
popAndPush(AppRoutes.unknownRoutePage); popAndPush(AppRoutes.unknownRoutePage);
} else if (failure is GetAllEmailFailure || failure is CleanAndGetAllEmailFailure) { } else if (failure is GetAllEmailFailure || failure is CleanAndGetAllEmailFailure) {
mailboxDashBoardController.updateRefreshAllEmailState(Left(RefreshAllEmailFailure())); mailboxDashBoardController.updateRefreshAllEmailState(Left(RefreshAllEmailFailure()));
canLoadMore = true;
} }
} }
@@ -540,6 +539,7 @@ class ThreadController extends BaseController with EmailActionController {
mailboxDashBoardController.listEmailSelected.value = listEmailSelected; mailboxDashBoardController.listEmailSelected.value = listEmailSelected;
} }
canLoadMore = newListEmail.length >= ThreadConstants.maxCountEmails; canLoadMore = newListEmail.length >= ThreadConstants.maxCountEmails;
loadingMoreStatus.value = LoadingMoreStatus.completed;
if (listEmailController.hasClients) { if (listEmailController.hasClients) {
listEmailController.jumpTo(0); listEmailController.jumpTo(0);
@@ -557,6 +557,7 @@ class ThreadController extends BaseController with EmailActionController {
} }
void _handleOnDoneGetAllEmailFailure() { void _handleOnDoneGetAllEmailFailure() {
canLoadMore = false;
if (PlatformInfo.isWeb && mailboxDashBoardController.isEmailListDisplayed) { if (PlatformInfo.isWeb && mailboxDashBoardController.isEmailListDisplayed) {
refocusMailShortcutFocus(); refocusMailShortcutFocus();
} }
@@ -586,7 +587,6 @@ class ThreadController extends BaseController with EmailActionController {
if (mailboxDashBoardController.isSelectionEnabled()) { if (mailboxDashBoardController.isSelectionEnabled()) {
mailboxDashBoardController.listEmailSelected.value = listEmailSelected; mailboxDashBoardController.listEmailSelected.value = listEmailSelected;
} }
canLoadMore = emailListSynced.length >= ThreadConstants.maxCountEmails;
if (PlatformInfo.isWeb) { if (PlatformInfo.isWeb) {
_validateBrowserHeight(); _validateBrowserHeight();
@@ -814,7 +814,9 @@ class ThreadController extends BaseController with EmailActionController {
void _loadMoreEmails() { void _loadMoreEmails() {
log('ThreadController::_loadMoreEmails()::canLoadMore = $canLoadMore'); log('ThreadController::_loadMoreEmails()::canLoadMore = $canLoadMore');
if (canLoadMore && _session != null && _accountId != null) { if (!canLoadMore) return;
if (_session != null && _accountId != null) {
final oldestEmail = mailboxDashBoardController.emailsInCurrentMailbox.isNotEmpty final oldestEmail = mailboxDashBoardController.emailsInCurrentMailbox.isNotEmpty
? mailboxDashBoardController.emailsInCurrentMailbox.last ? mailboxDashBoardController.emailsInCurrentMailbox.last
: null; : null;
@@ -832,6 +834,10 @@ class ThreadController extends BaseController with EmailActionController {
useCache: selectedMailbox?.isCacheable ?? false, useCache: selectedMailbox?.isCacheable ?? false,
) )
)); ));
} else {
consumeState(
Stream.value(Left(LoadMoreEmailsFailure(NotFoundSessionException()))),
);
} }
} }
@@ -1095,6 +1101,7 @@ class ThreadController extends BaseController with EmailActionController {
mailboxDashBoardController.listEmailSelected.value = listEmailSelected; mailboxDashBoardController.listEmailSelected.value = listEmailSelected;
} }
canSearchMore = newEmailListSynced.length >= ThreadConstants.maxCountEmails; canSearchMore = newEmailListSynced.length >= ThreadConstants.maxCountEmails;
loadingMoreStatus.value = LoadingMoreStatus.completed;
if (PlatformInfo.isWeb) { if (PlatformInfo.isWeb) {
_validateBrowserHeight(); _validateBrowserHeight();
@@ -1106,7 +1113,9 @@ class ThreadController extends BaseController with EmailActionController {
void _searchMoreEmails() { void _searchMoreEmails() {
log('ThreadController::_searchMoreEmails:'); log('ThreadController::_searchMoreEmails:');
if (canSearchMore && _session != null && _accountId != null) { if (!canSearchMore) return;
if (_session != null && _accountId != null) {
final lastEmail = mailboxDashBoardController.emailsInCurrentMailbox.isNotEmpty final lastEmail = mailboxDashBoardController.emailsInCurrentMailbox.isNotEmpty
? mailboxDashBoardController.emailsInCurrentMailbox.last ? mailboxDashBoardController.emailsInCurrentMailbox.last
: null; : null;
@@ -1133,6 +1142,10 @@ class ThreadController extends BaseController with EmailActionController {
properties: EmailUtils.getPropertiesForEmailGetMethod(_session!, _accountId!), properties: EmailUtils.getPropertiesForEmailGetMethod(_session!, _accountId!),
lastEmailId: lastEmail?.id lastEmailId: lastEmail?.id
)); ));
} else {
consumeState(
Stream.value(Left(SearchMoreEmailFailure(NotFoundSessionException()))),
);
} }
} }