TF-2930 Fix not persist hasRequestReadReceipt when reload browser
This commit is contained in:
+5
-13
@@ -1,22 +1,14 @@
|
||||
import 'package:core/presentation/utils/html_transformer/transform_configuration.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/model/screen_display_mode.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/data/model/composer_cache.dart';
|
||||
|
||||
abstract class SessionStorageComposerDatasource {
|
||||
Future<void> saveComposerCacheOnWeb(
|
||||
Email email,
|
||||
{
|
||||
required AccountId accountId,
|
||||
required UserName userName,
|
||||
required ScreenDisplayMode displayMode,
|
||||
Identity? identity,
|
||||
bool? readReceipentEnabled,
|
||||
}
|
||||
);
|
||||
Future<void> saveComposerCacheOnWeb({
|
||||
required AccountId accountId,
|
||||
required UserName userName,
|
||||
required ComposerCache composerCache,
|
||||
});
|
||||
|
||||
Future<ComposerCache> getComposerCacheOnWeb(
|
||||
AccountId accountId,
|
||||
|
||||
+9
-22
@@ -1,13 +1,12 @@
|
||||
import 'dart:convert';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:core/core.dart';
|
||||
import 'package:core/domain/exceptions/web_session_exception.dart';
|
||||
import 'package:core/presentation/utils/html_transformer/html_transform.dart';
|
||||
import 'package:core/presentation/utils/html_transformer/transform_configuration.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/caching/utils/cache_utils.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/model/screen_display_mode.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/data/datasource/session_storage_composer_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/data/model/composer_cache.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
@@ -50,30 +49,18 @@ class SessionStorageComposerDatasourceImpl
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> saveComposerCacheOnWeb(
|
||||
Email email,
|
||||
{
|
||||
required AccountId accountId,
|
||||
required UserName userName,
|
||||
required ScreenDisplayMode displayMode,
|
||||
Identity? identity,
|
||||
bool? readReceipentEnabled
|
||||
}
|
||||
) async {
|
||||
Future<void> saveComposerCacheOnWeb({
|
||||
required AccountId accountId,
|
||||
required UserName userName,
|
||||
required ComposerCache composerCache,
|
||||
}) async {
|
||||
return Future.sync(() {
|
||||
final composerCacheKey = TupleKey(
|
||||
EmailActionType.reopenComposerBrowser.name,
|
||||
accountId.asString,
|
||||
userName.value).toString();
|
||||
Map<String, String> entries = {
|
||||
composerCacheKey: jsonEncode(
|
||||
ComposerCache(
|
||||
displayMode: displayMode,
|
||||
email: email,
|
||||
identity: identity,
|
||||
readReceipentEnabled: readReceipentEnabled,
|
||||
).toJson()
|
||||
)
|
||||
composerCacheKey: jsonEncode(composerCache.toJson())
|
||||
};
|
||||
html.window.sessionStorage.addAll(entries);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
|
||||
@@ -1,44 +1,35 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/model/screen_display_mode.dart';
|
||||
|
||||
part 'composer_cache.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
class ComposerCache with EquatableMixin {
|
||||
|
||||
final Email? email;
|
||||
final Identity? identity;
|
||||
final bool? readReceipentEnabled;
|
||||
final bool? hasRequestReadReceipt;
|
||||
final ScreenDisplayMode displayMode;
|
||||
|
||||
ComposerCache({
|
||||
required this.displayMode,
|
||||
this.email,
|
||||
this.identity,
|
||||
this.readReceipentEnabled,
|
||||
this.hasRequestReadReceipt,
|
||||
this.displayMode = ScreenDisplayMode.normal
|
||||
});
|
||||
|
||||
factory ComposerCache.fromJson(Map<String, dynamic> json) => _$ComposerCacheFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$ComposerCacheToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
email,
|
||||
identity,
|
||||
readReceipentEnabled
|
||||
hasRequestReadReceipt,
|
||||
displayMode
|
||||
];
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return <String, dynamic>{
|
||||
'email': email?.toJson(),
|
||||
'identity': identity?.toJson(),
|
||||
'readReceipentEnabled': readReceipentEnabled,
|
||||
'displayMode': displayMode.toJson()
|
||||
};
|
||||
}
|
||||
|
||||
factory ComposerCache.fromJson(Map<String, dynamic> map) {
|
||||
return ComposerCache(
|
||||
displayMode: ScreenDisplayMode.fromJson(map['displayMode'] ?? ''),
|
||||
email: map['email'] != null ? Email.fromJson(map['email']) : null,
|
||||
identity: map['identity'] != null ? Identity.fromJson(map['identity']) : null,
|
||||
readReceipentEnabled: map['readReceipentEnabled'] as bool?
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import 'package:core/presentation/utils/html_transformer/transform_configuration.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/model/screen_display_mode.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/data/datasource/session_storage_composer_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/data/model/composer_cache.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/repository/composer_cache_repository.dart';
|
||||
@@ -28,23 +25,15 @@ class ComposerCacheRepositoryImpl extends ComposerCacheRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> saveComposerCacheOnWeb(
|
||||
Email email,
|
||||
{
|
||||
required AccountId accountId,
|
||||
required UserName userName,
|
||||
required ScreenDisplayMode displayMode,
|
||||
Identity? identity,
|
||||
bool? readReceipentEnabled
|
||||
}
|
||||
) {
|
||||
Future<void> saveComposerCacheOnWeb({
|
||||
required AccountId accountId,
|
||||
required UserName userName,
|
||||
required ComposerCache composerCache,
|
||||
}) {
|
||||
return composerCacheDataSource.saveComposerCacheOnWeb(
|
||||
email,
|
||||
accountId: accountId,
|
||||
userName: userName,
|
||||
displayMode: displayMode,
|
||||
identity: identity,
|
||||
readReceipentEnabled: readReceipentEnabled);
|
||||
composerCache: composerCache);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user