TF-340 Request to back-end with /query + /get in the case local cache has size < defaultLimit

This commit is contained in:
Dat PHAM HOANG
2022-03-16 21:56:07 +07:00
committed by Dat H. Pham
parent baedd9597a
commit 8bbe8b0bd7
2 changed files with 19 additions and 4 deletions
@@ -118,6 +118,7 @@ class ThreadController extends BaseController {
super.onReady();
mailboxDashBoardController.selectedMailbox.listen((selectedMailbox) {
if (_currentMailboxId != selectedMailbox?.id) {
log('ThreadController::onReady(): selectMailbox: ${selectedMailbox?.name?.name}(${selectedMailbox?.id})');
_currentMailboxId = selectedMailbox?.id;
_resetToOriginalValue();
_getAllEmail();
@@ -230,11 +231,13 @@ class ThreadController extends BaseController {
}
void _getAllEmailSuccess(GetAllEmailSuccess success) {
log('ThreadController::_getAllEmailSuccess(): ${success.emailList.length}');
_currentEmailState = success.currentEmailState;
emailList.value = success.emailList;
}
void _getAllEmailAction(AccountId accountId, {MailboxId? mailboxId}) {
log('ThreadController::_getAllEmailAction(): mailboxId = $mailboxId');
consumeState(_getEmailsInMailboxInteractor.execute(
accountId,
limit: ThreadConstants.defaultLimit,
@@ -338,8 +341,11 @@ class ThreadController extends BaseController {
}
void _loadMoreEmailsSuccess(LoadMoreEmailsSuccess success) {
log('ThreadController::_loadMoreEmailsSuccess(): [BEFORE] totalEmailList = ${emailList.length}');
if (success.emailList.isNotEmpty) {
log('ThreadController::_loadMoreEmailsSuccess(): add success: ${success.emailList.length}');
emailList.addAll(success.emailList);
log('ThreadController::_loadMoreEmailsSuccess(): [AFTER] totalEmailList = ${emailList.length}');
} else {
canLoadMore = false;
}