TF-123 Implement refresh all mailbox
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/mailbox_cache.dart';
|
||||
|
||||
extension ListMailboxCacheExtension on List<MailboxCache> {
|
||||
Map<String, MailboxCache> toMap() {
|
||||
return Map<String, MailboxCache>.fromIterable(
|
||||
this,
|
||||
key: (mailboxCache) => mailboxCache.id,
|
||||
value: (mailboxCache) => mailboxCache);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/mailbox_cache.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/extensions/mailbox_rights_cache_extension.dart';
|
||||
|
||||
extension MailboxCacheExtension on MailboxCache {
|
||||
Mailbox toMailbox() {
|
||||
return Mailbox(
|
||||
MailboxId(Id(id)),
|
||||
name != null ? MailboxName(name!) : null,
|
||||
parentId != null ? MailboxId(Id(parentId!)) : null,
|
||||
role != null ? Role(role!) : null,
|
||||
sortOrder != null ? SortOrder(sortValue: sortOrder!) : null,
|
||||
totalEmails != null ? TotalEmails(UnsignedInt(totalEmails!)) : null,
|
||||
unreadEmails != null ? UnreadEmails(UnsignedInt(unreadEmails!)) : null,
|
||||
totalThreads != null ? TotalThreads(UnsignedInt(totalThreads!)) : null,
|
||||
unreadThreads != null ? UnreadThreads(UnsignedInt(unreadThreads!)) : null,
|
||||
myRights != null ? myRights!.toMailboxRights() : null,
|
||||
isSubscribed != null ? IsSubscribed(isSubscribed!) : null
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/mailbox_change_response.dart';
|
||||
|
||||
extension MailboxChangeResponseExtension on MailboxChangeResponse {
|
||||
|
||||
MailboxChangeResponse updatedMailboxChangeResponse(List<Mailbox>? updatedMailbox) {
|
||||
return MailboxChangeResponse(
|
||||
updated: updatedMailbox,
|
||||
created: created,
|
||||
destroyed: destroyed,
|
||||
newStateMailbox: newStateMailbox,
|
||||
newStateChanges: newStateChanges,
|
||||
hasMoreChanges: hasMoreChanges,
|
||||
updatedProperties: updatedProperties
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/mailbox_cache.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/extensions/mailbox_rights_extension.dart';
|
||||
|
||||
extension MailboxExtension on Mailbox {
|
||||
|
||||
MailboxCache toMailboxCache() {
|
||||
return MailboxCache(
|
||||
id.id.value,
|
||||
name: name?.name,
|
||||
parentId: parentId?.id.value,
|
||||
role: role?.value,
|
||||
sortOrder: sortOrder?.value.value.round(),
|
||||
totalEmails: totalEmails?.value.value.round(),
|
||||
unreadEmails: unreadEmails?.value.value.round(),
|
||||
totalThreads: totalThreads?.value.value.round(),
|
||||
unreadThreads: unreadThreads?.value.value.round(),
|
||||
myRights: myRights != null ? myRights!.toMailboxRightsCache() : null,
|
||||
isSubscribed: isSubscribed?.value
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox_rights.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/mailbox_rights_cache.dart';
|
||||
|
||||
extension MailboxRightsCacheExtension on MailboxRightsCache {
|
||||
MailboxRights toMailboxRights() {
|
||||
return MailboxRights(
|
||||
mayReadItems,
|
||||
mayAddItems,
|
||||
mayRemoveItems,
|
||||
maySetSeen,
|
||||
maySetKeywords,
|
||||
mayCreateChild,
|
||||
mayRename,
|
||||
mayDelete,
|
||||
maySubmit
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox_rights.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/mailbox_rights_cache.dart';
|
||||
|
||||
extension MailboxRightsExtension on MailboxRights {
|
||||
MailboxRightsCache toMailboxRightsCache() {
|
||||
return MailboxRightsCache(
|
||||
mayReadItems,
|
||||
mayAddItems,
|
||||
mayRemoveItems,
|
||||
maySetSeen,
|
||||
maySetKeywords,
|
||||
mayCreateChild,
|
||||
mayRename,
|
||||
mayDelete,
|
||||
maySubmit
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/state_cache.dart';
|
||||
|
||||
extension StateCacheExtension on StateCache {
|
||||
State toState() {
|
||||
return State(state);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/state_cache.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/state_type.dart';
|
||||
|
||||
extension StateExtension on State {
|
||||
StateCache toStateCache(StateType stateType) {
|
||||
return StateCache(stateType, value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user