TF-4314 Fix unread emails disappear blink (#4316)
This commit is contained in:
@@ -83,6 +83,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
session,
|
||||
accountId,
|
||||
sort: sort,
|
||||
limit: limit,
|
||||
position: position,
|
||||
mailboxId: emailFilter?.mailboxId,
|
||||
propertiesCreated: propertiesCreated,
|
||||
@@ -187,6 +188,16 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
'Server email count = $serverCount',
|
||||
);
|
||||
|
||||
if (serverCount > 0 ||
|
||||
(serverResponse.notFoundEmailIds?.isNotEmpty ?? false)) {
|
||||
await _updateEmailCache(
|
||||
accountId,
|
||||
session.username,
|
||||
newCreated: serverResponse.emailList,
|
||||
newDestroyed: serverResponse.notFoundEmailIds,
|
||||
);
|
||||
}
|
||||
|
||||
// Combine server list + keep existing state
|
||||
yield EmailsResponse(
|
||||
emailList: serverResponse.emailList,
|
||||
@@ -203,6 +214,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
AccountId accountId,
|
||||
{
|
||||
Set<Comparator>? sort,
|
||||
UnsignedInt? limit,
|
||||
int? position,
|
||||
MailboxId? mailboxId,
|
||||
Properties? propertiesCreated,
|
||||
@@ -212,7 +224,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
final networkEmailResponse = await mapDataSource[DataSourceType.network]!.getAllEmail(
|
||||
session,
|
||||
accountId,
|
||||
limit: ThreadConstants.defaultLimit,
|
||||
limit: limit ?? ThreadConstants.defaultLimit,
|
||||
position: position,
|
||||
sort: sort,
|
||||
filter: filter ?? EmailFilterCondition(inMailbox: mailboxId),
|
||||
@@ -323,6 +335,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
jmap.State currentState,
|
||||
{
|
||||
Set<Comparator>? sort,
|
||||
UnsignedInt? limit,
|
||||
EmailFilter? emailFilter,
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated,
|
||||
@@ -343,19 +356,26 @@ class ThreadRepositoryImpl extends ThreadRepository {
|
||||
session.username,
|
||||
inMailboxId: emailFilter?.mailboxId,
|
||||
sort: sort,
|
||||
filterOption: emailFilter?.filterOption
|
||||
limit: limit,
|
||||
filterOption: emailFilter?.filterOption,
|
||||
),
|
||||
stateDataSource.getState(accountId, session.username, StateType.email)
|
||||
]).then((List response) {
|
||||
return EmailsResponse(emailList: response.first, state: response.last);
|
||||
});
|
||||
|
||||
final currentLimitEmails =
|
||||
limit?.value ?? ThreadConstants.defaultLimit.value;
|
||||
|
||||
log('ThreadRepositoryImpl::refreshChanges: Current limit emails is $currentLimitEmails');
|
||||
|
||||
if (!newEmailResponse.hasEmails()
|
||||
|| (newEmailResponse.emailList?.length ?? 0) < ThreadConstants.defaultLimit.value) {
|
||||
|| (newEmailResponse.emailList?.length ?? 0) < currentLimitEmails) {
|
||||
final networkEmailResponse = await _getFirstPage(
|
||||
session,
|
||||
accountId,
|
||||
sort: sort,
|
||||
limit: limit,
|
||||
filter: emailFilter?.filter,
|
||||
mailboxId: emailFilter?.mailboxId,
|
||||
propertiesCreated: propertiesCreated,
|
||||
|
||||
@@ -59,6 +59,7 @@ abstract class ThreadRepository {
|
||||
jmap.State currentState,
|
||||
{
|
||||
Set<Comparator>? sort,
|
||||
UnsignedInt? limit,
|
||||
EmailFilter? emailFilter,
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated,
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/sort/comparator.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/email_filter.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/email_response.dart';
|
||||
@@ -23,6 +24,7 @@ class RefreshChangesEmailsInMailboxInteractor {
|
||||
jmap.State currentState,
|
||||
{
|
||||
Set<Comparator>? sort,
|
||||
UnsignedInt? limit,
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated,
|
||||
EmailFilter? emailFilter,
|
||||
@@ -37,6 +39,7 @@ class RefreshChangesEmailsInMailboxInteractor {
|
||||
accountId,
|
||||
currentState,
|
||||
sort: sort,
|
||||
limit: limit,
|
||||
propertiesCreated: propertiesCreated,
|
||||
propertiesUpdated: propertiesUpdated,
|
||||
emailFilter: emailFilter)
|
||||
|
||||
@@ -719,6 +719,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
_accountId!,
|
||||
mailboxDashBoardController.currentEmailState!,
|
||||
sort: EmailSortOrderType.mostRecent.getSortOrder().toNullable(),
|
||||
limit: limitEmailFetched,
|
||||
propertiesCreated: EmailUtils.getPropertiesForEmailGetMethod(
|
||||
_session!,
|
||||
_accountId!,
|
||||
|
||||
Reference in New Issue
Block a user