TF-3767 Use TupleKey to save recent search for each account
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
+19
-3
@@ -1,7 +1,11 @@
|
||||
import 'dart:core';
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/repository/search_repository.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/state/get_all_recent_search_latest_state.dart';
|
||||
|
||||
@@ -10,9 +14,21 @@ class GetAllRecentSearchLatestInteractor {
|
||||
|
||||
GetAllRecentSearchLatestInteractor(this.searchRepository);
|
||||
|
||||
Future<Either<Failure, Success>> execute({int? limit, String? pattern}) async {
|
||||
Future<Either<Failure, Success>> execute(
|
||||
AccountId accountId,
|
||||
UserName userName,
|
||||
{
|
||||
int? limit,
|
||||
String? pattern,
|
||||
}
|
||||
) async {
|
||||
try {
|
||||
final listRecent = await searchRepository.getAllRecentSearchLatest(limit: limit, pattern: pattern);
|
||||
final listRecent = await searchRepository.getAllRecentSearchLatest(
|
||||
accountId,
|
||||
userName,
|
||||
limit: limit,
|
||||
pattern: pattern,
|
||||
);
|
||||
log('GetAllRecentSearchLatestInteractor::execute(): listRecent: ${listRecent.length}');
|
||||
return Right(GetAllRecentSearchLatestSuccess(listRecent));
|
||||
} catch (exception) {
|
||||
|
||||
@@ -2,6 +2,8 @@ import 'dart:core';
|
||||
|
||||
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/user_name.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/model/recent_search.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/repository/search_repository.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/state/save_recent_search_state.dart';
|
||||
@@ -11,9 +13,17 @@ class SaveRecentSearchInteractor {
|
||||
|
||||
SaveRecentSearchInteractor(this.searchRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(RecentSearch recentSearch) async* {
|
||||
Stream<Either<Failure, Success>> execute(
|
||||
AccountId accountId,
|
||||
UserName userName,
|
||||
RecentSearch recentSearch,
|
||||
) async* {
|
||||
try {
|
||||
await searchRepository.saveRecentSearch(recentSearch);
|
||||
await searchRepository.saveRecentSearch(
|
||||
accountId,
|
||||
userName,
|
||||
recentSearch,
|
||||
);
|
||||
yield Right(SaveRecentSearchSuccess());
|
||||
} catch (exception) {
|
||||
yield Left(SaveRecentSearchFailure(exception));
|
||||
|
||||
Reference in New Issue
Block a user