From 979ba0f671a63badad12293532468461bcf98f75 Mon Sep 17 00:00:00 2001 From: Dang Dat Date: Wed, 1 Apr 2026 16:16:39 +0700 Subject: [PATCH] TF-4308 add data layer for addListLabelToListEmails --- .../data/datasource/email_datasource.dart | 10 ++++++++++ .../email_datasource_impl.dart | 20 +++++++++++++++++++ .../email_hive_cache_datasource_impl.dart | 13 ++++++++++++ .../email_local_storage_datasource_impl.dart | 13 ++++++++++++ ...email_session_storage_datasource_impl.dart | 13 ++++++++++++ .../email/data/network/email_api.dart | 20 +++++++++++++++++++ .../repository/email_repository_impl.dart | 18 +++++++++++++++++ .../domain/repository/email_repository.dart | 10 ++++++++++ 8 files changed, 117 insertions(+) diff --git a/lib/features/email/data/datasource/email_datasource.dart b/lib/features/email/data/datasource/email_datasource.dart index f0c93160c..13ccd9456 100644 --- a/lib/features/email/data/datasource/email_datasource.dart +++ b/lib/features/email/data/datasource/email_datasource.dart @@ -238,4 +238,14 @@ abstract class EmailDataSource { List emailIds, KeyWordIdentifier labelKeyword, ); + + Future<({ + List emailIdsSuccess, + Map mapErrors, + })> addListLabelToListEmail( + Session session, + AccountId accountId, + List emailIds, + List labelKeywords, + ); } \ No newline at end of file diff --git a/lib/features/email/data/datasource_impl/email_datasource_impl.dart b/lib/features/email/data/datasource_impl/email_datasource_impl.dart index 8be3021fc..692edf4c8 100644 --- a/lib/features/email/data/datasource_impl/email_datasource_impl.dart +++ b/lib/features/email/data/datasource_impl/email_datasource_impl.dart @@ -627,4 +627,24 @@ class EmailDataSourceImpl extends EmailDataSource { ); }).catchError(_exceptionThrower.throwException); } + + @override + Future<({ + List emailIdsSuccess, + Map mapErrors, + })> addListLabelToListEmail( + Session session, + AccountId accountId, + List emailIds, + List labelKeywords, + ) { + return Future.sync(() async { + return await emailAPI.addListLabelToListEmail( + session, + accountId, + emailIds, + labelKeywords, + ); + }).catchError(_exceptionThrower.throwException); + } } \ No newline at end of file diff --git a/lib/features/email/data/datasource_impl/email_hive_cache_datasource_impl.dart b/lib/features/email/data/datasource_impl/email_hive_cache_datasource_impl.dart index 863b65876..d029bc472 100644 --- a/lib/features/email/data/datasource_impl/email_hive_cache_datasource_impl.dart +++ b/lib/features/email/data/datasource_impl/email_hive_cache_datasource_impl.dart @@ -601,4 +601,17 @@ class EmailHiveCacheDataSourceImpl extends EmailDataSource { })> removeLabelFromThread(Session session, AccountId accountId, List emailIds, KeyWordIdentifier labelKeyword) { throw UnimplementedError(); } + + @override + Future<({ + List emailIdsSuccess, + Map mapErrors, + })> addListLabelToListEmail( + Session session, + AccountId accountId, + List emailIds, + List labelKeywords, + ) { + throw UnimplementedError(); + } } \ No newline at end of file diff --git a/lib/features/email/data/datasource_impl/email_local_storage_datasource_impl.dart b/lib/features/email/data/datasource_impl/email_local_storage_datasource_impl.dart index 3f07d47ff..61069c23b 100644 --- a/lib/features/email/data/datasource_impl/email_local_storage_datasource_impl.dart +++ b/lib/features/email/data/datasource_impl/email_local_storage_datasource_impl.dart @@ -377,4 +377,17 @@ class EmailLocalStorageDataSourceImpl extends EmailDataSource { })> removeLabelFromThread(Session session, AccountId accountId, List emailIds, KeyWordIdentifier labelKeyword) { throw UnimplementedError(); } + + @override + Future<({ + List emailIdsSuccess, + Map mapErrors, + })> addListLabelToListEmail( + Session session, + AccountId accountId, + List emailIds, + List labelKeywords, + ) { + throw UnimplementedError(); + } } \ No newline at end of file diff --git a/lib/features/email/data/datasource_impl/email_session_storage_datasource_impl.dart b/lib/features/email/data/datasource_impl/email_session_storage_datasource_impl.dart index 8078f9d54..d957c3fce 100644 --- a/lib/features/email/data/datasource_impl/email_session_storage_datasource_impl.dart +++ b/lib/features/email/data/datasource_impl/email_session_storage_datasource_impl.dart @@ -291,4 +291,17 @@ class EmailSessionStorageDatasourceImpl extends EmailDataSource { })> removeLabelFromThread(Session session, AccountId accountId, List emailIds, KeyWordIdentifier labelKeyword) { throw UnimplementedError(); } + + @override + Future<({ + List emailIdsSuccess, + Map mapErrors, + })> addListLabelToListEmail( + Session session, + AccountId accountId, + List emailIds, + List labelKeywords, + ) { + throw UnimplementedError(); + } } \ No newline at end of file diff --git a/lib/features/email/data/network/email_api.dart b/lib/features/email/data/network/email_api.dart index 81652d852..1e3f65cde 100644 --- a/lib/features/email/data/network/email_api.dart +++ b/lib/features/email/data/network/email_api.dart @@ -970,4 +970,24 @@ class EmailAPI ), ); } + + Future<({ + List emailIdsSuccess, + Map mapErrors, + })> addListLabelToListEmail( + Session session, + AccountId accountId, + List emailIds, + List labelKeywords, + ) async { + return executeBatchSetEmail( + session: session, + accountId: accountId, + emailIds: emailIds, + httpClient: _httpClient, + debugLabel: 'addListLabelToListEmail', + onGenerateUpdates: (batchIds) => + batchIds.generateMapUpdateObjectListLabel(labelKeywords), + ); + } } \ No newline at end of file diff --git a/lib/features/email/data/repository/email_repository_impl.dart b/lib/features/email/data/repository/email_repository_impl.dart index 198a66585..5f5b5dfb4 100644 --- a/lib/features/email/data/repository/email_repository_impl.dart +++ b/lib/features/email/data/repository/email_repository_impl.dart @@ -546,4 +546,22 @@ class EmailRepositoryImpl extends EmailRepository { labelKeyword, ); } + + @override + Future<({ + List emailIdsSuccess, + Map mapErrors, + })> addListLabelToListEmail( + Session session, + AccountId accountId, + List emailIds, + List labelKeywords, + ) { + return emailDataSource[DataSourceType.network]!.addListLabelToListEmail( + session, + accountId, + emailIds, + labelKeywords, + ); + } } \ No newline at end of file diff --git a/lib/features/email/domain/repository/email_repository.dart b/lib/features/email/domain/repository/email_repository.dart index 50542d791..01f322c90 100644 --- a/lib/features/email/domain/repository/email_repository.dart +++ b/lib/features/email/domain/repository/email_repository.dart @@ -195,4 +195,14 @@ abstract class EmailRepository { List emailIds, KeyWordIdentifier labelKeyword, ); + + Future<({ + List emailIdsSuccess, + Map mapErrors, + })> addListLabelToListEmail( + Session session, + AccountId accountId, + List emailIds, + List labelKeywords, + ); } \ No newline at end of file