Use GetAllEmails instead of RefreshAll Interactor
This commit is contained in:
committed by
Dat H. Pham
parent
9c53b4a948
commit
a66b33472d
@@ -22,17 +22,6 @@ abstract class ThreadRepository {
|
||||
}
|
||||
);
|
||||
|
||||
Stream<EmailsResponse> refreshAll(
|
||||
AccountId accountId,
|
||||
{
|
||||
UnsignedInt? limit,
|
||||
Set<Comparator>? sort,
|
||||
EmailFilter? emailFilter,
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated,
|
||||
}
|
||||
);
|
||||
|
||||
Stream<EmailsResponse> refreshChanges(
|
||||
AccountId accountId,
|
||||
jmap.State currentState,
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
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/sort/comparator.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/email_response.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/repository/thread_repository.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/get_all_email_state.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
class RefreshAllEmailsInMailboxInteractor {
|
||||
final ThreadRepository threadRepository;
|
||||
|
||||
RefreshAllEmailsInMailboxInteractor(this.threadRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(
|
||||
AccountId accountId,
|
||||
{
|
||||
UnsignedInt? limit,
|
||||
Set<Comparator>? sort,
|
||||
EmailFilter? emailFilter,
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated,
|
||||
}
|
||||
) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(LoadingState());
|
||||
|
||||
yield* threadRepository
|
||||
.refreshAll(
|
||||
accountId,
|
||||
limit: limit,
|
||||
sort: sort,
|
||||
emailFilter: emailFilter,
|
||||
propertiesCreated: propertiesCreated,
|
||||
propertiesUpdated: propertiesUpdated)
|
||||
.map(_toGetEmailState);
|
||||
} catch (e) {
|
||||
yield Left(GetAllEmailFailure(e));
|
||||
}
|
||||
}
|
||||
|
||||
Either<Failure, Success> _toGetEmailState(EmailsResponse emailResponse) {
|
||||
final presentationEmailList = emailResponse.emailList
|
||||
?.map((email) => email.toPresentationEmail()).toList() ?? List.empty();
|
||||
|
||||
return Right<Failure, Success>(GetAllEmailSuccess(
|
||||
emailList: presentationEmailList,
|
||||
currentEmailState: emailResponse.state));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user