TF-3332 Prevent refresh when switching mailbox
This commit is contained in:
@@ -45,6 +45,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
|||||||
EmailFilter? emailFilter,
|
EmailFilter? emailFilter,
|
||||||
Properties? propertiesCreated,
|
Properties? propertiesCreated,
|
||||||
Properties? propertiesUpdated,
|
Properties? propertiesUpdated,
|
||||||
|
bool getLatestChanges = true,
|
||||||
}
|
}
|
||||||
) async* {
|
) async* {
|
||||||
log('ThreadRepositoryImpl::getAllEmail(): filter = ${emailFilter?.mailboxId}');
|
log('ThreadRepositoryImpl::getAllEmail(): filter = ${emailFilter?.mailboxId}');
|
||||||
@@ -92,7 +93,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
|||||||
await _updateEmailCache(accountId, session.username, newCreated: networkEmailResponse.emailList);
|
await _updateEmailCache(accountId, session.username, newCreated: networkEmailResponse.emailList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localEmailResponse.hasState()) {
|
if (localEmailResponse.hasState() && getLatestChanges) {
|
||||||
log('ThreadRepositoryImpl::getAllEmail(): filter = ${emailFilter?.mailboxId} local has state: ${localEmailResponse.state}');
|
log('ThreadRepositoryImpl::getAllEmail(): filter = ${emailFilter?.mailboxId} local has state: ${localEmailResponse.state}');
|
||||||
await _synchronizeCacheWithChanges(
|
await _synchronizeCacheWithChanges(
|
||||||
session,
|
session,
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ abstract class ThreadRepository {
|
|||||||
EmailFilter? emailFilter,
|
EmailFilter? emailFilter,
|
||||||
Properties? propertiesCreated,
|
Properties? propertiesCreated,
|
||||||
Properties? propertiesUpdated,
|
Properties? propertiesUpdated,
|
||||||
|
bool getLatestChanges = true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class GetEmailsInMailboxInteractor {
|
|||||||
EmailFilter? emailFilter,
|
EmailFilter? emailFilter,
|
||||||
Properties? propertiesCreated,
|
Properties? propertiesCreated,
|
||||||
Properties? propertiesUpdated,
|
Properties? propertiesUpdated,
|
||||||
|
bool getLatestChanges = true,
|
||||||
}
|
}
|
||||||
) async* {
|
) async* {
|
||||||
try {
|
try {
|
||||||
@@ -39,7 +40,8 @@ class GetEmailsInMailboxInteractor {
|
|||||||
sort: sort,
|
sort: sort,
|
||||||
emailFilter: emailFilter,
|
emailFilter: emailFilter,
|
||||||
propertiesCreated: propertiesCreated,
|
propertiesCreated: propertiesCreated,
|
||||||
propertiesUpdated: propertiesUpdated)
|
propertiesUpdated: propertiesUpdated,
|
||||||
|
getLatestChanges: getLatestChanges)
|
||||||
.map((emailResponse) => _toGetEmailState(
|
.map((emailResponse) => _toGetEmailState(
|
||||||
emailResponse: emailResponse,
|
emailResponse: emailResponse,
|
||||||
currentMailboxId: emailFilter?.mailboxId
|
currentMailboxId: emailFilter?.mailboxId
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
_currentMemoryMailboxId = mailbox.id;
|
_currentMemoryMailboxId = mailbox.id;
|
||||||
consumeState(Stream.value(Right(GetAllEmailLoading())));
|
consumeState(Stream.value(Right(GetAllEmailLoading())));
|
||||||
_resetToOriginalValue();
|
_resetToOriginalValue();
|
||||||
_getAllEmailAction();
|
_getAllEmailAction(getLatestChanges: false);
|
||||||
} else if (mailbox == null) { // disable current mailbox when search active
|
} else if (mailbox == null) { // disable current mailbox when search active
|
||||||
_currentMemoryMailboxId = null;
|
_currentMemoryMailboxId = null;
|
||||||
_resetToOriginalValue();
|
_resetToOriginalValue();
|
||||||
@@ -446,7 +446,7 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _getAllEmailAction() {
|
void _getAllEmailAction({bool getLatestChanges = true}) {
|
||||||
log('ThreadController::_getAllEmailAction:');
|
log('ThreadController::_getAllEmailAction:');
|
||||||
if (_session != null &&_accountId != null) {
|
if (_session != null &&_accountId != null) {
|
||||||
consumeState(_getEmailsInMailboxInteractor.execute(
|
consumeState(_getEmailsInMailboxInteractor.execute(
|
||||||
@@ -461,6 +461,7 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
),
|
),
|
||||||
propertiesCreated: EmailUtils.getPropertiesForEmailGetMethod(_session!, _accountId!),
|
propertiesCreated: EmailUtils.getPropertiesForEmailGetMethod(_session!, _accountId!),
|
||||||
propertiesUpdated: ThreadConstants.propertiesUpdatedDefault,
|
propertiesUpdated: ThreadConstants.propertiesUpdatedDefault,
|
||||||
|
getLatestChanges: getLatestChanges,
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
consumeState(Stream.value(Left(GetAllEmailFailure(NotFoundSessionException()))));
|
consumeState(Stream.value(Left(GetAllEmailFailure(NotFoundSessionException()))));
|
||||||
|
|||||||
Reference in New Issue
Block a user