diff --git a/lib/features/caching/utils/caching_constants.dart b/lib/features/caching/utils/caching_constants.dart index 17cd34819..7871ca1e1 100644 --- a/lib/features/caching/utils/caching_constants.dart +++ b/lib/features/caching/utils/caching_constants.dart @@ -14,6 +14,9 @@ class CachingConstants { static const int RECENT_LOGIN_URL_HIVE_CACHE_IDENTITY = 12; static const int RECENT_LOGIN_USERNAME_HIVE_CACHE_IDENTITY = 13; static const int FCM_SUBSCRIPTION_HIVE_CACHE_IDENTITY = 14; + static const int ATTACHMENT_HIVE_CACHE_ID = 15; + static const int EMAIL_HEADER_HIVE_CACHE_ID = 16; + static const int DETAILED_EMAIL_HIVE_CACHE_ID = 17; static const String fcmCacheBoxName = 'fcm_cache_box'; } \ No newline at end of file diff --git a/lib/features/offline_mode/model/attachment_hive_cache.dart b/lib/features/offline_mode/model/attachment_hive_cache.dart new file mode 100644 index 000000000..2d0985d8a --- /dev/null +++ b/lib/features/offline_mode/model/attachment_hive_cache.dart @@ -0,0 +1,52 @@ + +import 'package:equatable/equatable.dart'; +import 'package:hive/hive.dart'; +import 'package:tmail_ui_user/features/caching/utils/caching_constants.dart'; + +part 'attachment_hive_cache.g.dart'; + +@HiveType(typeId: CachingConstants.ATTACHMENT_HIVE_CACHE_ID) +class AttachmentHiveCache extends HiveObject with EquatableMixin { + + @HiveField(0) + final String? partId; + + @HiveField(1) + final String? blobId; + + @HiveField(2) + final int? size; + + @HiveField(3) + final String? name; + + @HiveField(4) + final String? type; + + @HiveField(5) + final String? cid; + + @HiveField(6) + final String? disposition; + + AttachmentHiveCache({ + this.partId, + this.blobId, + this.size, + this.name, + this.type, + this.cid, + this.disposition + }); + + @override + List get props => [ + partId, + blobId, + size, + name, + type, + cid, + disposition + ]; +} \ No newline at end of file diff --git a/lib/features/offline_mode/model/detailed_email_hive_cache.dart b/lib/features/offline_mode/model/detailed_email_hive_cache.dart new file mode 100644 index 000000000..47aa405ac --- /dev/null +++ b/lib/features/offline_mode/model/detailed_email_hive_cache.dart @@ -0,0 +1,45 @@ + +import 'package:equatable/equatable.dart'; +import 'package:hive/hive.dart'; +import 'package:tmail_ui_user/features/caching/utils/caching_constants.dart'; +import 'package:tmail_ui_user/features/offline_mode/model/email_header_hive_cache.dart'; + +import 'attachment_hive_cache.dart'; + +part 'detailed_email_hive_cache.g.dart'; + +@HiveType(typeId: CachingConstants.DETAILED_EMAIL_HIVE_CACHE_ID) +class DetailedEmailHiveCache extends HiveObject with EquatableMixin { + + @HiveField(0) + final String emailId; + + @HiveField(1) + final DateTime timeSaved; + + @HiveField(2) + final List? attachments; + + @HiveField(3) + final String? emailContentPath; + + @HiveField(4) + final List? headers; + + DetailedEmailHiveCache({ + required this.emailId, + required this.timeSaved, + this.attachments, + this.emailContentPath, + this.headers + }); + + @override + List get props => [ + emailId, + timeSaved, + attachments, + emailContentPath, + headers + ]; +} \ No newline at end of file diff --git a/lib/features/offline_mode/model/email_header_hive_cache.dart b/lib/features/offline_mode/model/email_header_hive_cache.dart new file mode 100644 index 000000000..09db0f6e6 --- /dev/null +++ b/lib/features/offline_mode/model/email_header_hive_cache.dart @@ -0,0 +1,21 @@ + +import 'package:equatable/equatable.dart'; +import 'package:hive/hive.dart'; +import 'package:tmail_ui_user/features/caching/utils/caching_constants.dart'; + +part 'email_header_hive_cache.g.dart'; + +@HiveType(typeId: CachingConstants.EMAIL_HEADER_HIVE_CACHE_ID) +class EmailHeaderHiveCache extends HiveObject with EquatableMixin { + + @HiveField(0) + final String name; + + @HiveField(1) + final String value; + + EmailHeaderHiveCache({required this.name, required this.value}); + + @override + List get props => [name, value]; +} \ No newline at end of file