TF-123 Implement refresh all mailbox
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/mailbox_rights_cache.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/utils/caching_constants.dart';
|
||||
|
||||
part 'mailbox_cache.g.dart';
|
||||
|
||||
@HiveType(typeId: CachingConstants.MAILBOX_CACHE_IDENTIFY)
|
||||
class MailboxCache extends HiveObject with EquatableMixin {
|
||||
|
||||
@HiveField(0)
|
||||
final String id;
|
||||
|
||||
@HiveField(1)
|
||||
final String? name;
|
||||
|
||||
@HiveField(2)
|
||||
final String? parentId;
|
||||
|
||||
@HiveField(3)
|
||||
final String? role;
|
||||
|
||||
@HiveField(4)
|
||||
final int? sortOrder;
|
||||
|
||||
@HiveField(5)
|
||||
final int? totalEmails;
|
||||
|
||||
@HiveField(6)
|
||||
final int? unreadEmails;
|
||||
|
||||
@HiveField(7)
|
||||
final int? totalThreads;
|
||||
|
||||
@HiveField(8)
|
||||
final int? unreadThreads;
|
||||
|
||||
@HiveField(9)
|
||||
final MailboxRightsCache? myRights;
|
||||
|
||||
@HiveField(10)
|
||||
final bool? isSubscribed;
|
||||
|
||||
@HiveField(11)
|
||||
final DateTime? lastOpened;
|
||||
|
||||
MailboxCache(
|
||||
this.id,
|
||||
{
|
||||
this.name,
|
||||
this.parentId,
|
||||
this.role,
|
||||
this.sortOrder,
|
||||
this.totalEmails,
|
||||
this.unreadEmails,
|
||||
this.totalThreads,
|
||||
this.unreadThreads,
|
||||
this.myRights,
|
||||
this.isSubscribed,
|
||||
this.lastOpened
|
||||
}
|
||||
);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
name,
|
||||
parentId,
|
||||
role,
|
||||
unreadEmails,
|
||||
lastOpened,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'mailbox_cache.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class MailboxCacheAdapter extends TypeAdapter<MailboxCache> {
|
||||
@override
|
||||
final int typeId = 1;
|
||||
|
||||
@override
|
||||
MailboxCache read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return MailboxCache(
|
||||
fields[0] as String,
|
||||
name: fields[1] as String?,
|
||||
parentId: fields[2] as String?,
|
||||
role: fields[3] as String?,
|
||||
sortOrder: fields[4] as int?,
|
||||
totalEmails: fields[5] as int?,
|
||||
unreadEmails: fields[6] as int?,
|
||||
totalThreads: fields[7] as int?,
|
||||
unreadThreads: fields[8] as int?,
|
||||
myRights: fields[9] as MailboxRightsCache?,
|
||||
isSubscribed: fields[10] as bool?,
|
||||
lastOpened: fields[11] as DateTime?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, MailboxCache obj) {
|
||||
writer
|
||||
..writeByte(12)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.name)
|
||||
..writeByte(2)
|
||||
..write(obj.parentId)
|
||||
..writeByte(3)
|
||||
..write(obj.role)
|
||||
..writeByte(4)
|
||||
..write(obj.sortOrder)
|
||||
..writeByte(5)
|
||||
..write(obj.totalEmails)
|
||||
..writeByte(6)
|
||||
..write(obj.unreadEmails)
|
||||
..writeByte(7)
|
||||
..write(obj.totalThreads)
|
||||
..writeByte(8)
|
||||
..write(obj.unreadThreads)
|
||||
..writeByte(9)
|
||||
..write(obj.myRights)
|
||||
..writeByte(10)
|
||||
..write(obj.isSubscribed)
|
||||
..writeByte(11)
|
||||
..write(obj.lastOpened);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is MailboxCacheAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
class MailboxCacheResponse with EquatableMixin {
|
||||
final List<MailboxCache>? mailboxCaches;
|
||||
final StateDao? oldState;
|
||||
|
||||
MailboxCacheResponse({
|
||||
this.mailboxCaches,
|
||||
this.oldState
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [mailboxCaches, oldState];
|
||||
}
|
||||
@@ -8,17 +8,29 @@ class MailboxChangeResponse with EquatableMixin {
|
||||
final List<Mailbox>? updated;
|
||||
final List<Mailbox>? created;
|
||||
final List<MailboxId>? destroyed;
|
||||
final State? newState;
|
||||
final State? newStateMailbox;
|
||||
final State? newStateChanges;
|
||||
final bool hasMoreChanges;
|
||||
final Properties? updatedProperties;
|
||||
|
||||
MailboxChangeResponse({
|
||||
this.updated,
|
||||
this.created,
|
||||
this.destroyed,
|
||||
this.newState,
|
||||
this.newStateMailbox,
|
||||
this.newStateChanges,
|
||||
this.hasMoreChanges = false,
|
||||
this.updatedProperties,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [updated, created, destroyed, newState, updatedProperties];
|
||||
List<Object?> get props => [
|
||||
updated,
|
||||
created,
|
||||
destroyed,
|
||||
newStateMailbox,
|
||||
newStateChanges,
|
||||
hasMoreChanges,
|
||||
updatedProperties
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
|
||||
class MailboxResponse with EquatableMixin {
|
||||
final List<Mailbox>? mailboxes;
|
||||
final State? state;
|
||||
|
||||
MailboxResponse({
|
||||
this.mailboxes,
|
||||
this.state
|
||||
});
|
||||
|
||||
bool hasData() {
|
||||
return mailboxes != null
|
||||
&& mailboxes!.isNotEmpty
|
||||
&& state != null;
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [mailboxes, state];
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/utils/caching_constants.dart';
|
||||
|
||||
part 'mailbox_rights_cache.g.dart';
|
||||
|
||||
@HiveType(typeId: CachingConstants.MAILBOX_RIGHTS_CACHE_IDENTIFY)
|
||||
class MailboxRightsCache extends HiveObject with EquatableMixin {
|
||||
|
||||
@HiveField(0)
|
||||
final bool mayReadItems;
|
||||
|
||||
@HiveField(1)
|
||||
final bool mayAddItems;
|
||||
|
||||
@HiveField(2)
|
||||
final bool mayRemoveItems;
|
||||
|
||||
@HiveField(3)
|
||||
final bool maySetSeen;
|
||||
|
||||
@HiveField(4)
|
||||
final bool maySetKeywords;
|
||||
|
||||
@HiveField(5)
|
||||
final bool mayCreateChild;
|
||||
|
||||
@HiveField(6)
|
||||
final bool mayRename;
|
||||
|
||||
@HiveField(7)
|
||||
final bool mayDelete;
|
||||
|
||||
@HiveField(8)
|
||||
final bool maySubmit;
|
||||
|
||||
MailboxRightsCache(
|
||||
this.mayReadItems,
|
||||
this.mayAddItems,
|
||||
this.mayRemoveItems,
|
||||
this.maySetSeen,
|
||||
this.maySetKeywords,
|
||||
this.mayCreateChild,
|
||||
this.mayRename,
|
||||
this.mayDelete,
|
||||
this.maySubmit
|
||||
);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
mayReadItems,
|
||||
mayAddItems,
|
||||
mayRemoveItems,
|
||||
maySetSeen,
|
||||
maySetKeywords,
|
||||
mayCreateChild,
|
||||
mayRename,
|
||||
mayDelete,
|
||||
maySubmit
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'mailbox_rights_cache.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class MailboxRightsCacheAdapter extends TypeAdapter<MailboxRightsCache> {
|
||||
@override
|
||||
final int typeId = 2;
|
||||
|
||||
@override
|
||||
MailboxRightsCache read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return MailboxRightsCache(
|
||||
fields[0] as bool,
|
||||
fields[1] as bool,
|
||||
fields[2] as bool,
|
||||
fields[3] as bool,
|
||||
fields[4] as bool,
|
||||
fields[5] as bool,
|
||||
fields[6] as bool,
|
||||
fields[7] as bool,
|
||||
fields[8] as bool,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, MailboxRightsCache obj) {
|
||||
writer
|
||||
..writeByte(9)
|
||||
..writeByte(0)
|
||||
..write(obj.mayReadItems)
|
||||
..writeByte(1)
|
||||
..write(obj.mayAddItems)
|
||||
..writeByte(2)
|
||||
..write(obj.mayRemoveItems)
|
||||
..writeByte(3)
|
||||
..write(obj.maySetSeen)
|
||||
..writeByte(4)
|
||||
..write(obj.maySetKeywords)
|
||||
..writeByte(5)
|
||||
..write(obj.mayCreateChild)
|
||||
..writeByte(6)
|
||||
..write(obj.mayRename)
|
||||
..writeByte(7)
|
||||
..write(obj.mayDelete)
|
||||
..writeByte(8)
|
||||
..write(obj.maySubmit);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is MailboxRightsCacheAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/state_type.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/utils/caching_constants.dart';
|
||||
|
||||
part 'state_cache.g.dart';
|
||||
|
||||
@HiveType(typeId: CachingConstants.STATE_CACHE_IDENTIFY)
|
||||
class StateCache extends HiveObject with EquatableMixin {
|
||||
|
||||
@HiveField(0)
|
||||
final StateType type;
|
||||
|
||||
@HiveField(1)
|
||||
final String state;
|
||||
|
||||
StateCache(this.type, this.state);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [type, state];
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'state_cache.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class StateCacheAdapter extends TypeAdapter<StateCache> {
|
||||
@override
|
||||
final int typeId = 3;
|
||||
|
||||
@override
|
||||
StateCache read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return StateCache(
|
||||
fields[0] as StateType,
|
||||
fields[1] as String,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, StateCache obj) {
|
||||
writer
|
||||
..writeByte(2)
|
||||
..writeByte(0)
|
||||
..write(obj.type)
|
||||
..writeByte(1)
|
||||
..write(obj.state);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is StateCacheAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/utils/caching_constants.dart';
|
||||
|
||||
part 'state_type.g.dart';
|
||||
|
||||
@HiveType(typeId: CachingConstants.STATE_TYPE_IDENTIFY)
|
||||
enum StateType {
|
||||
|
||||
@HiveField(0)
|
||||
mailbox
|
||||
}
|
||||
|
||||
extension StateTypeExtension on StateType {
|
||||
String get value {
|
||||
switch(this) {
|
||||
case StateType.mailbox:
|
||||
return 'mailbox';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'state_type.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class StateTypeAdapter extends TypeAdapter<StateType> {
|
||||
@override
|
||||
final int typeId = 4;
|
||||
|
||||
@override
|
||||
StateType read(BinaryReader reader) {
|
||||
switch (reader.readByte()) {
|
||||
case 0:
|
||||
return StateType.mailbox;
|
||||
default:
|
||||
return StateType.mailbox;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, StateType obj) {
|
||||
switch (obj) {
|
||||
case StateType.mailbox:
|
||||
writer.writeByte(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is StateTypeAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
Reference in New Issue
Block a user