TF-3372 Adding onProgressController to interactor layer
This commit is contained in:
committed by
Dat H. Pham
parent
a81d33f98b
commit
da0a3a9da6
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
@@ -12,10 +14,24 @@ class EmptySpamFolderInteractor {
|
||||
|
||||
EmptySpamFolderInteractor(this.threadRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(Session session, AccountId accountId, MailboxId spamMailboxId) async* {
|
||||
Stream<Either<Failure, Success>> execute(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
MailboxId spamMailboxId,
|
||||
int totalEmails,
|
||||
StreamController<Either<Failure, Success>> onProgressController
|
||||
) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(EmptySpamFolderLoading());
|
||||
final emailIdDeleted = await threadRepository.emptySpamFolder(session, accountId, spamMailboxId);
|
||||
onProgressController.add(Right(EmptySpamFolderLoading()));
|
||||
|
||||
final emailIdDeleted = await threadRepository.emptySpamFolder(
|
||||
session,
|
||||
accountId,
|
||||
spamMailboxId,
|
||||
totalEmails,
|
||||
onProgressController
|
||||
);
|
||||
yield Right<Failure, Success>(EmptySpamFolderSuccess(emailIdDeleted));
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(EmptySpamFolderFailure(e));
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
@@ -12,10 +14,24 @@ class EmptyTrashFolderInteractor {
|
||||
|
||||
EmptyTrashFolderInteractor(this.threadRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(Session session, AccountId accountId, MailboxId trashMailboxId) async* {
|
||||
Stream<Either<Failure, Success>> execute(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
MailboxId trashMailboxId,
|
||||
int totalEmails,
|
||||
StreamController<Either<Failure, Success>> onProgressController
|
||||
) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(EmptyTrashFolderLoading());
|
||||
final emailIdDeleted = await threadRepository.emptyTrashFolder(session, accountId, trashMailboxId);
|
||||
onProgressController.add(Right(EmptyTrashFolderLoading()));
|
||||
|
||||
final emailIdDeleted = await threadRepository.emptyTrashFolder(
|
||||
session,
|
||||
accountId,
|
||||
trashMailboxId,
|
||||
totalEmails,
|
||||
onProgressController
|
||||
);
|
||||
yield Right<Failure, Success>(EmptyTrashFolderSuccess(emailIdDeleted,));
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(EmptyTrashFolderFailure(e));
|
||||
|
||||
Reference in New Issue
Block a user