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 SearchingState extends LoadingState {}
|
||||||
|
|
||||||
|
class RefreshingSearchState extends LoadingState {}
|
||||||
|
|
||||||
class SearchEmailSuccess extends UIState {
|
class SearchEmailSuccess extends UIState {
|
||||||
final List<PresentationEmail> emailList;
|
final List<PresentationEmail> emailList;
|
||||||
|
|
||||||
|
|||||||
@@ -26,10 +26,15 @@ class SearchEmailInteractor {
|
|||||||
Set<Comparator>? sort,
|
Set<Comparator>? sort,
|
||||||
Filter? filter,
|
Filter? filter,
|
||||||
Properties? properties,
|
Properties? properties,
|
||||||
|
bool isRefreshChange = false,
|
||||||
}
|
}
|
||||||
) async* {
|
) async* {
|
||||||
try {
|
try {
|
||||||
yield Right(SearchingState());
|
if (isRefreshChange) {
|
||||||
|
yield Right(RefreshingSearchState());
|
||||||
|
} else {
|
||||||
|
yield Right(SearchingState());
|
||||||
|
}
|
||||||
|
|
||||||
final emailList = await threadRepository.searchEmails(
|
final emailList = await threadRepository.searchEmails(
|
||||||
session,
|
session,
|
||||||
|
|||||||
@@ -578,7 +578,7 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
void _refreshEmailChanges({jmap.State? currentEmailState}) {
|
void _refreshEmailChanges({jmap.State? currentEmailState}) {
|
||||||
log('ThreadController::_refreshEmailChanges(): currentEmailState: $currentEmailState');
|
log('ThreadController::_refreshEmailChanges(): currentEmailState: $currentEmailState');
|
||||||
if (searchController.isSearchEmailRunning) {
|
if (searchController.isSearchEmailRunning) {
|
||||||
_searchEmail(limit: limitEmailFetched);
|
_searchEmail(limit: limitEmailFetched, isRefreshChange: true);
|
||||||
} else {
|
} else {
|
||||||
final newEmailState = currentEmailState ?? _currentEmailState;
|
final newEmailState = currentEmailState ?? _currentEmailState;
|
||||||
log('ThreadController::_refreshEmailChanges(): newEmailState: $newEmailState');
|
log('ThreadController::_refreshEmailChanges(): newEmailState: $newEmailState');
|
||||||
@@ -802,12 +802,14 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
searchController.clearTextSearch();
|
searchController.clearTextSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _searchEmail({UnsignedInt? limit}) {
|
void _searchEmail({UnsignedInt? limit, bool isRefreshChange = false}) {
|
||||||
if (_session != null && _accountId != null) {
|
if (_session != null && _accountId != null) {
|
||||||
if (listEmailController.hasClients) {
|
if (!isRefreshChange && listEmailController.hasClients) {
|
||||||
listEmailController.jumpTo(0);
|
listEmailController.jumpTo(0);
|
||||||
}
|
}
|
||||||
mailboxDashBoardController.emailsInCurrentMailbox.clear();
|
if (!isRefreshChange) {
|
||||||
|
mailboxDashBoardController.emailsInCurrentMailbox.clear();
|
||||||
|
}
|
||||||
canSearchMore = false;
|
canSearchMore = false;
|
||||||
|
|
||||||
searchController.updateFilterEmail(
|
searchController.updateFilterEmail(
|
||||||
@@ -826,6 +828,7 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
moreFilterCondition: _getFilterCondition()
|
moreFilterCondition: _getFilterCondition()
|
||||||
),
|
),
|
||||||
properties: EmailUtils.getPropertiesForEmailGetMethod(_session!, _accountId!),
|
properties: EmailUtils.getPropertiesForEmailGetMethod(_session!, _accountId!),
|
||||||
|
isRefreshChange: isRefreshChange
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
consumeState(Stream.value(Left(SearchEmailFailure(NotFoundSessionException()))));
|
consumeState(Stream.value(Left(SearchEmailFailure(NotFoundSessionException()))));
|
||||||
|
|||||||
Reference in New Issue
Block a user