TF-3025 Avoid search results being reloaded when performing certain actions read/star/...
This commit is contained in:
@@ -4,6 +4,8 @@ import 'package:model/email/presentation_email.dart';
|
||||
|
||||
class SearchingState extends LoadingState {}
|
||||
|
||||
class RefreshingSearchState extends LoadingState {}
|
||||
|
||||
class SearchEmailSuccess extends UIState {
|
||||
final List<PresentationEmail> emailList;
|
||||
|
||||
|
||||
@@ -26,10 +26,15 @@ class SearchEmailInteractor {
|
||||
Set<Comparator>? sort,
|
||||
Filter? filter,
|
||||
Properties? properties,
|
||||
bool isRefreshChange = false,
|
||||
}
|
||||
) async* {
|
||||
try {
|
||||
yield Right(SearchingState());
|
||||
if (isRefreshChange) {
|
||||
yield Right(RefreshingSearchState());
|
||||
} else {
|
||||
yield Right(SearchingState());
|
||||
}
|
||||
|
||||
final emailList = await threadRepository.searchEmails(
|
||||
session,
|
||||
|
||||
@@ -578,7 +578,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
void _refreshEmailChanges({jmap.State? currentEmailState}) {
|
||||
log('ThreadController::_refreshEmailChanges(): currentEmailState: $currentEmailState');
|
||||
if (searchController.isSearchEmailRunning) {
|
||||
_searchEmail(limit: limitEmailFetched);
|
||||
_searchEmail(limit: limitEmailFetched, isRefreshChange: true);
|
||||
} else {
|
||||
final newEmailState = currentEmailState ?? _currentEmailState;
|
||||
log('ThreadController::_refreshEmailChanges(): newEmailState: $newEmailState');
|
||||
@@ -802,12 +802,14 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
searchController.clearTextSearch();
|
||||
}
|
||||
|
||||
void _searchEmail({UnsignedInt? limit}) {
|
||||
void _searchEmail({UnsignedInt? limit, bool isRefreshChange = false}) {
|
||||
if (_session != null && _accountId != null) {
|
||||
if (listEmailController.hasClients) {
|
||||
if (!isRefreshChange && listEmailController.hasClients) {
|
||||
listEmailController.jumpTo(0);
|
||||
}
|
||||
mailboxDashBoardController.emailsInCurrentMailbox.clear();
|
||||
if (!isRefreshChange) {
|
||||
mailboxDashBoardController.emailsInCurrentMailbox.clear();
|
||||
}
|
||||
canSearchMore = false;
|
||||
|
||||
searchController.updateFilterEmail(
|
||||
@@ -826,6 +828,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
moreFilterCondition: _getFilterCondition()
|
||||
),
|
||||
properties: EmailUtils.getPropertiesForEmailGetMethod(_session!, _accountId!),
|
||||
isRefreshChange: isRefreshChange
|
||||
));
|
||||
} else {
|
||||
consumeState(Stream.value(Left(SearchEmailFailure(NotFoundSessionException()))));
|
||||
|
||||
Reference in New Issue
Block a user