Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TF-3345 Fix sort order blinks when deleting emails in search #3437

Open
wants to merge 1 commit into
base: maintenance-v0.14.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,12 @@ class SearchEmailFilter with EquatableMixin, OptionParamMixin {
? text?.value.trim()
: null,
inMailbox: mailbox?.mailboxId,
after: sortOrderType.isScrollByPosition()
? null
: emailReceiveTimeType.getAfterDate(startDate),
after: emailReceiveTimeType.getAfterDate(startDate),
hasAttachment: !hasAttachment ? null : hasAttachment,
subject: subject?.trim().isNotEmpty == true
? subject?.trim()
: null,
before: sortOrderType.isScrollByPosition()
? null
: emailReceiveTimeType.getBeforeDate(endDate, before),
before: emailReceiveTimeType.getBeforeDate(endDate, before),
from: from.length == 1
? from.first
: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ class SearchEmailController extends BaseController
currentSearchText.value = value;
_updateSimpleSearchFilter(
textOption: option(value.isNotEmpty, SearchQuery(value)),
beforeOption: const None(),
beforeOption: !searchEmailFilter.value.sortOrderType.isScrollByPosition()
? const None()
: null,
positionOption: option(searchEmailFilter.value.sortOrderType.isScrollByPosition(), 0)
);
if (value.isNotEmpty && session != null && accountId != null) {
Expand Down Expand Up @@ -319,7 +321,9 @@ class SearchEmailController extends BaseController
: ThreadConstants.defaultLimit;

_updateSimpleSearchFilter(
beforeOption: const None(),
beforeOption: !searchEmailFilter.value.sortOrderType.isScrollByPosition()
? const None()
: null,
positionOption: option(searchEmailFilter.value.sortOrderType.isScrollByPosition(), 0),
);

Expand Down Expand Up @@ -435,7 +439,9 @@ class SearchEmailController extends BaseController

_updateSimpleSearchFilter(
positionOption: option(searchEmailFilter.value.sortOrderType.isScrollByPosition(), 0),
beforeOption: const None(),
beforeOption: !searchEmailFilter.value.sortOrderType.isScrollByPosition()
? const None()
: null,
);

consumeState(_searchEmailInteractor.execute(
Expand Down Expand Up @@ -484,10 +490,7 @@ class SearchEmailController extends BaseController
final lastEmail = listResultSearch.last;

if (searchEmailFilter.value.sortOrderType.isScrollByPosition()) {
_updateSimpleSearchFilter(
positionOption: Some(listResultSearch.length),
beforeOption: const None()
);
_updateSimpleSearchFilter(positionOption: Some(listResultSearch.length));
} else if (searchEmailFilter.value.sortOrderType == EmailSortOrderType.oldest) {
_updateSimpleSearchFilter(startDateOption: optionOf(lastEmail.receivedAt));
} else {
Expand Down
14 changes: 8 additions & 6 deletions lib/features/thread/presentation/thread_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,9 @@ class ThreadController extends BaseController with EmailActionController {
_searchEmailFilter.sortOrderType.isScrollByPosition(),
0,
),
beforeOption: const None(),
beforeOption: !_searchEmailFilter.sortOrderType.isScrollByPosition()
? const None()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a good idea in case:

  • user search in a range of time, but when it refreshes, before is not applied

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, it still works correctly in this case. Please review the details.

: null,
);
final searchViewState = await _searchEmailInteractor.execute(
_session!,
Expand Down Expand Up @@ -949,7 +951,10 @@ class ThreadController extends BaseController with EmailActionController {

searchController.updateFilterEmail(
positionOption: option(_searchEmailFilter.sortOrderType.isScrollByPosition(), 0),
beforeOption: const None());
beforeOption: !_searchEmailFilter.sortOrderType.isScrollByPosition()
? const None()
: null,
);

searchController.activateSimpleSearch();

Expand Down Expand Up @@ -1023,10 +1028,7 @@ class ThreadController extends BaseController with EmailActionController {
if (_searchEmailFilter.sortOrderType.isScrollByPosition()) {
final nextPosition = mailboxDashBoardController.emailsInCurrentMailbox.length;
log('ThreadController::_searchMoreEmails:nextPosition: $nextPosition');
searchController.updateFilterEmail(
positionOption: Some(nextPosition),
beforeOption: const None()
);
searchController.updateFilterEmail(positionOption: Some(nextPosition));
} else if (_searchEmailFilter.sortOrderType == EmailSortOrderType.oldest) {
searchController.updateFilterEmail(startDateOption: optionOf(lastEmail?.receivedAt));
} else {
Expand Down
Loading