TF-35 Implement search mailbox

This commit is contained in:
dab246
2022-02-23 18:45:34 +07:00
committed by Dat H. Pham
parent 9cca03fff3
commit ba453f71b2
9 changed files with 130 additions and 23 deletions
@@ -0,0 +1,21 @@
import 'package:core/core.dart';
import 'package:dartz/dartz.dart';
import 'package:model/model.dart';
import 'package:tmail_ui_user/features/mailbox/domain/state/search_mailbox_state.dart';
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
class SearchMailboxInteractor {
Stream<Either<Failure, Success>> execute(List<PresentationMailbox> mailboxes, SearchQuery searchQuery) async* {
try {
final resultList = mailboxes
.where((mailbox) => mailbox.name?.name.toLowerCase().contains(searchQuery.value.toLowerCase()) == true)
.toList();
yield Right<Failure, Success>(SearchMailboxSuccess(resultList));
} catch (exception) {
yield Left<Failure, Success>(SearchMailboxFailure(exception));
}
}
}