Use GetAllEmails instead of RefreshAll Interactor

This commit is contained in:
Dat PHAM HOANG
2022-04-26 10:45:45 +07:00
committed by Dat H. Pham
parent 9c53b4a948
commit a66b33472d
5 changed files with 4 additions and 118 deletions
@@ -189,6 +189,7 @@ class ThreadRepositoryImpl extends ThreadRepository {
FilterMessageOption? filterOption,
}
) async* {
log('ThreadRepositoryImpl::refreshChanges(): $currentState');
final localEmailList = await mapDataSource[DataSourceType.local]!.getAllEmailCache(
inMailboxId: inMailboxId,
sort: sort,
@@ -289,42 +290,6 @@ class ThreadRepositoryImpl extends ThreadRepository {
return emailResponse.emailList ?? List.empty();
}
@override
Stream<EmailsResponse> refreshAll(
AccountId accountId,
{
UnsignedInt? limit,
Set<Comparator>? sort,
EmailFilter? emailFilter,
Properties? propertiesCreated,
Properties? propertiesUpdated,
}
) async* {
EmailsResponse? networkEmailResponse = await mapDataSource[DataSourceType.network]!.getAllEmail(
accountId,
limit: limit,
sort: sort,
filter: emailFilter?.filter,
properties: propertiesCreated);
await _updateEmailCache(newCreated: networkEmailResponse.emailList);
if (networkEmailResponse.state != null) {
await _updateState(networkEmailResponse.state!);
}
final newEmailResponse = await Future.wait([
mapDataSource[DataSourceType.local]!.getAllEmailCache(
inMailboxId: emailFilter?.mailboxId,
sort: sort,
filterOption: emailFilter?.filterOption),
stateDataSource.getState(StateType.email)
]).then((List response) {
return EmailsResponse(emailList: response.first, state: response.last);
});
yield newEmailResponse;
}
@override
Future<bool> emptyTrashFolder(AccountId accountId, MailboxId trashMailboxId) async {
var finalResult = true;