TF-145 Add data layer for getAllEmail in Caching
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/filter/filter.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/state.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/datasource/thread_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/local/email_cache_manager.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/model/email_change_response.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/email_response.dart';
|
||||
|
||||
class LocalThreadDataSourceImpl extends ThreadDataSource {
|
||||
|
||||
final EmailCacheManager _emailCacheManager;
|
||||
|
||||
LocalThreadDataSourceImpl(this._emailCacheManager);
|
||||
|
||||
@override
|
||||
Future<EmailResponse> getAllEmail(
|
||||
AccountId accountId,
|
||||
{
|
||||
int? position,
|
||||
UnsignedInt? limit,
|
||||
Set<Comparator>? sort,
|
||||
Filter? filter,
|
||||
Properties? properties
|
||||
}
|
||||
) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<EmailChangeResponse> getChanges(
|
||||
AccountId accountId,
|
||||
State sinceState,
|
||||
{
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated
|
||||
}
|
||||
) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Email>> getAllEmailCache({MailboxId? inMailboxId, Set<Comparator>? sort}) {
|
||||
return Future.sync(() async {
|
||||
return await _emailCacheManager.getAllEmail(inMailboxId: inMailboxId, sort: sort);
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> update({List<Email>? updated, List<Email>? created, List<EmailId>? destroyed}) {
|
||||
return Future.sync(() async {
|
||||
return await _emailCacheManager.update(updated: updated, created: created, destroyed: destroyed);
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,13 @@ import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/filter/filter.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/state.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/datasource/thread_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/model/email_change_response.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/email_response.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/network/thread_api.dart';
|
||||
|
||||
class ThreadDataSourceImpl extends ThreadDataSource {
|
||||
@@ -14,14 +18,17 @@ class ThreadDataSourceImpl extends ThreadDataSource {
|
||||
ThreadDataSourceImpl(this.threadAPI);
|
||||
|
||||
@override
|
||||
Future<List<Email>> getAllEmail(
|
||||
Future<EmailResponse> getAllEmail(
|
||||
AccountId accountId,
|
||||
{
|
||||
int? position,
|
||||
UnsignedInt? limit,
|
||||
Set<Comparator>? sort,
|
||||
Filter? filter,
|
||||
Properties? properties
|
||||
Properties? properties,
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated,
|
||||
MailboxId? inMailboxId
|
||||
}
|
||||
) {
|
||||
return Future.sync(() async {
|
||||
@@ -36,4 +43,34 @@ class ThreadDataSourceImpl extends ThreadDataSource {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<EmailChangeResponse> getChanges(
|
||||
AccountId accountId,
|
||||
State sinceState,
|
||||
{
|
||||
Properties? propertiesCreated,
|
||||
Properties? propertiesUpdated
|
||||
}
|
||||
) {
|
||||
return Future.sync(() async {
|
||||
return await threadAPI.getChanges(
|
||||
accountId,
|
||||
sinceState,
|
||||
propertiesCreated: propertiesCreated,
|
||||
propertiesUpdated: propertiesUpdated);
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Email>> getAllEmailCache({MailboxId? inMailboxId, Set<Comparator>? sort}) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> update({List<Email>? updated, List<Email>? created, List<EmailId>? destroyed}) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user