TF-3082 Warn user and save identity cache on reload/session expired
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/model/identity_cache.dart';
|
||||
|
||||
abstract class IdentityCreatorDataSource {
|
||||
Future<void> saveIdentityCacheOnWeb(
|
||||
AccountId accountId,
|
||||
UserName userName,
|
||||
{required IdentityCache identityCache});
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:model/extensions/account_id_extensions.dart';
|
||||
import 'package:tmail_ui_user/features/caching/utils/cache_utils.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/data/datasource/identity_creator_data_source.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/data/model/identity_cache_model.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/model/identity_cache.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
import 'package:universal_html/html.dart';
|
||||
|
||||
class LocalIdentityCreatorDataSourceImpl implements IdentityCreatorDataSource {
|
||||
LocalIdentityCreatorDataSourceImpl(this._exceptionThrower);
|
||||
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
static const sessionStorageKeyword = 'identityCreatorSessionStorage';
|
||||
|
||||
@override
|
||||
Future<void> saveIdentityCacheOnWeb(
|
||||
AccountId accountId,
|
||||
UserName userName,
|
||||
{required IdentityCache identityCache}
|
||||
) async {
|
||||
return Future.sync(() {
|
||||
final cacheKey = _generateTupleKey(accountId, userName);
|
||||
Map<String, String> entries = {
|
||||
cacheKey: jsonEncode(IdentityCacheModel.fromDomain(identityCache).toJson())
|
||||
};
|
||||
window.sessionStorage.addAll(entries);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
String _generateTupleKey(AccountId accountId, UserName userName) {
|
||||
return TupleKey(
|
||||
LocalIdentityCreatorDataSourceImpl.sessionStorageKeyword,
|
||||
accountId.asString,
|
||||
userName.value
|
||||
).toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/model/identity_cache.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/identity_action_type.dart';
|
||||
import 'package:tmail_ui_user/features/public_asset/data/model/public_assets_in_identity_arguments_model.dart';
|
||||
|
||||
part 'identity_cache_model.g.dart';
|
||||
|
||||
@JsonSerializable(includeIfNull: false, explicitToJson: true)
|
||||
class IdentityCacheModel extends IdentityCache {
|
||||
IdentityCacheModel({
|
||||
required super.identity,
|
||||
required super.identityActionType,
|
||||
required super.isDefault,
|
||||
required this.publicAssetsInIdentityArgumentsModel})
|
||||
: super(publicAssetsInIdentityArguments: publicAssetsInIdentityArgumentsModel);
|
||||
|
||||
final PublicAssetsInIdentityArgumentsModel? publicAssetsInIdentityArgumentsModel;
|
||||
|
||||
factory IdentityCacheModel.fromJson(Map<String, dynamic> json)
|
||||
=> _$IdentityCacheModelFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$IdentityCacheModelToJson(this);
|
||||
|
||||
factory IdentityCacheModel.fromDomain(IdentityCache identityCache) {
|
||||
return IdentityCacheModel(
|
||||
identity: identityCache.identity,
|
||||
identityActionType: identityCache.identityActionType,
|
||||
isDefault: identityCache.isDefault,
|
||||
publicAssetsInIdentityArgumentsModel: identityCache.publicAssetsInIdentityArguments == null
|
||||
? null
|
||||
: PublicAssetsInIdentityArgumentsModel.fromDomain(identityCache.publicAssetsInIdentityArguments!)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/data/datasource/identity_creator_data_source.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/model/identity_cache.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/repository/identity_creator_repository.dart';
|
||||
|
||||
class IdentityCreatorRepositoryImpl implements IdentityCreatorRepository {
|
||||
IdentityCreatorRepositoryImpl(this._identityCreatorDataSource);
|
||||
|
||||
final IdentityCreatorDataSource _identityCreatorDataSource;
|
||||
|
||||
@override
|
||||
Future<void> saveIdentityCacheOnWeb(
|
||||
AccountId accountId,
|
||||
UserName userName,
|
||||
{required IdentityCache identityCache}
|
||||
) => _identityCreatorDataSource.saveIdentityCacheOnWeb(
|
||||
accountId,
|
||||
userName,
|
||||
identityCache: identityCache);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/identity_action_type.dart';
|
||||
import 'package:tmail_ui_user/features/public_asset/domain/model/public_assets_in_identity_arguments.dart';
|
||||
|
||||
class IdentityCache with EquatableMixin {
|
||||
final Identity? identity;
|
||||
final IdentityActionType identityActionType;
|
||||
final bool isDefault;
|
||||
final PublicAssetsInIdentityArguments? publicAssetsInIdentityArguments;
|
||||
|
||||
IdentityCache({
|
||||
required this.identity,
|
||||
required this.identityActionType,
|
||||
required this.isDefault,
|
||||
required this.publicAssetsInIdentityArguments});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
identity,
|
||||
identityActionType,
|
||||
isDefault,
|
||||
publicAssetsInIdentityArguments];
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/model/identity_cache.dart';
|
||||
|
||||
abstract class IdentityCreatorRepository {
|
||||
Future<void> saveIdentityCacheOnWeb(
|
||||
AccountId accountId,
|
||||
UserName userName,
|
||||
{required IdentityCache identityCache});
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
|
||||
class SavingIdentityCacheOnWeb extends LoadingState {}
|
||||
|
||||
class SaveIdentityCacheOnWebSuccess extends UIState {}
|
||||
|
||||
class SaveIdentityCacheOnWebFailure extends FeatureFailure {
|
||||
SaveIdentityCacheOnWebFailure({super.exception});
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/model/identity_cache.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/repository/identity_creator_repository.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/state/save_identity_cache_on_web_state.dart';
|
||||
|
||||
class SaveIdentityCacheOnWebInteractor {
|
||||
SaveIdentityCacheOnWebInteractor(this._identityCreatorRepository);
|
||||
|
||||
final IdentityCreatorRepository _identityCreatorRepository;
|
||||
|
||||
Stream<Either<Failure, Success>> execute(
|
||||
AccountId accountId,
|
||||
UserName userName,
|
||||
{required IdentityCache identityCache}
|
||||
) async* {
|
||||
try {
|
||||
yield Right(SavingIdentityCacheOnWeb());
|
||||
await _identityCreatorRepository.saveIdentityCacheOnWeb(
|
||||
accountId,
|
||||
userName,
|
||||
identityCache: identityCache);
|
||||
yield Right(SaveIdentityCacheOnWebSuccess());
|
||||
} catch (exception) {
|
||||
logError("$runtimeType::execute: $exception");
|
||||
yield Left(SaveIdentityCacheOnWebFailure(exception: exception));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,58 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/data/datasource/identity_creator_data_source.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/data/datasource_impl/local_identity_creator_data_source_impl.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/data/repository/identity_creator_repository_impl.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/repository/identity_creator_repository.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/usecase/save_identity_cache_on_web_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/presentation/identity_creator_controller.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/domain/usecases/verify_name_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/get_all_identities_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/profiles/identities/identity_interactors_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/profiles/identities/utils/identity_utils.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart';
|
||||
|
||||
class IdentityCreatorBindings extends Bindings {
|
||||
|
||||
class IdentityCreatorBindings extends BaseBindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
IdentityInteractorsBindings().dependencies();
|
||||
Get.lazyPut(() => VerifyNameInteractor());
|
||||
|
||||
void bindingsController() {
|
||||
Get.lazyPut(() => IdentityCreatorController(
|
||||
Get.find<VerifyNameInteractor>(),
|
||||
Get.find<GetAllIdentitiesInteractor>(),
|
||||
Get.find<SaveIdentityCacheOnWebInteractor>(),
|
||||
Get.find<IdentityUtils>()
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSource() {
|
||||
Get.lazyPut<IdentityCreatorDataSource>(() => Get.find<LocalIdentityCreatorDataSourceImpl>());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsDataSourceImpl() {
|
||||
Get.lazyPut(() => LocalIdentityCreatorDataSourceImpl(
|
||||
Get.find<CacheExceptionThrower>()
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsInteractor() {
|
||||
IdentityInteractorsBindings().dependencies();
|
||||
Get.lazyPut(() => VerifyNameInteractor());
|
||||
Get.lazyPut(() => SaveIdentityCacheOnWebInteractor(
|
||||
Get.find<IdentityCreatorRepository>()
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepository() {
|
||||
Get.lazyPut<IdentityCreatorRepository>(() => Get.find<IdentityCreatorRepositoryImpl>());
|
||||
}
|
||||
|
||||
@override
|
||||
void bindingsRepositoryImpl() {
|
||||
Get.lazyPut(() => IdentityCreatorRepositoryImpl(
|
||||
Get.find<IdentityCreatorDataSource>()
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -35,8 +35,12 @@ import 'package:path_provider/path_provider.dart';
|
||||
import 'package:rich_text_composer/rich_text_composer.dart';
|
||||
import 'package:rich_text_composer/views/commons/constants.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||
import 'package:tmail_ui_user/features/base/before_reconnect_handler.dart';
|
||||
import 'package:tmail_ui_user/features/base/before_reconnect_manager.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/controller/rich_text_web_controller.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/model/identity_cache.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/domain/usecase/save_identity_cache_on_web_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/mixin/drag_drog_file_mixin.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/presentation/model/identity_creator_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/identity_creator/presentation/utils/identity_creator_constants.dart';
|
||||
@@ -67,10 +71,11 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
import 'package:tmail_ui_user/main/universal_import/html_stub.dart' as html hide File;
|
||||
|
||||
class IdentityCreatorController extends BaseController with DragDropFileMixin {
|
||||
class IdentityCreatorController extends BaseController with DragDropFileMixin implements BeforeReconnectHandler {
|
||||
|
||||
final VerifyNameInteractor _verifyNameInteractor;
|
||||
final GetAllIdentitiesInteractor _getAllIdentitiesInteractor;
|
||||
final SaveIdentityCacheOnWebInteractor _saveIdentityCacheOnWebInteractor;
|
||||
final IdentityUtils _identityUtils;
|
||||
|
||||
final noneEmailAddress = EmailAddress(null, 'None');
|
||||
@@ -99,6 +104,7 @@ class IdentityCreatorController extends BaseController with DragDropFileMixin {
|
||||
StreamSubscription<html.Event>? _subscriptionOnDragOver;
|
||||
StreamSubscription<html.Event>? _subscriptionOnDragLeave;
|
||||
StreamSubscription<html.Event>? _subscriptionOnDrop;
|
||||
final _beforeReconnectManager = Get.find<BeforeReconnectManager>();
|
||||
|
||||
String? _nameIdentity;
|
||||
String? _contentHtmlEditor;
|
||||
@@ -139,6 +145,7 @@ class IdentityCreatorController extends BaseController with DragDropFileMixin {
|
||||
IdentityCreatorController(
|
||||
this._verifyNameInteractor,
|
||||
this._getAllIdentitiesInteractor,
|
||||
this._saveIdentityCacheOnWebInteractor,
|
||||
this._identityUtils
|
||||
);
|
||||
|
||||
@@ -152,6 +159,7 @@ class IdentityCreatorController extends BaseController with DragDropFileMixin {
|
||||
}
|
||||
log('IdentityCreatorController::onInit():arguments: ${Get.arguments}');
|
||||
arguments = Get.arguments;
|
||||
_beforeReconnectManager.addListener(onBeforeReconnect);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -243,6 +251,7 @@ class IdentityCreatorController extends BaseController with DragDropFileMixin {
|
||||
_subscriptionOnDragOver?.cancel();
|
||||
_subscriptionOnDragLeave?.cancel();
|
||||
_subscriptionOnDrop?.cancel();
|
||||
_beforeReconnectManager.removeListener(onBeforeReconnect);
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@@ -277,7 +286,21 @@ class IdentityCreatorController extends BaseController with DragDropFileMixin {
|
||||
if (PlatformInfo.isWeb) {
|
||||
richTextWebController?.editorController.setText(arguments?.identity?.signatureAsString ?? '');
|
||||
}
|
||||
publicAssetController?.getOldPublicAssetFromHtmlContent(arguments!.identity!.signatureAsString);
|
||||
}
|
||||
_initPublicAssetController();
|
||||
}
|
||||
|
||||
void _initPublicAssetController() {
|
||||
final publicAssetsInIdentityArguments = arguments?.publicAssetsInIdentityArguments;
|
||||
final htmlSignature = arguments?.identity?.signatureAsString;
|
||||
|
||||
if (publicAssetsInIdentityArguments != null) {
|
||||
publicAssetController?.restorePreExistingPublicAssetsFromCache(
|
||||
publicAssetsInIdentityArguments.preExistingPublicAssetIds);
|
||||
publicAssetController?.restoreNewlyPickedPublicAssetsFromCache(
|
||||
publicAssetsInIdentityArguments.newlyPickedPublicAssetIds);
|
||||
} else if (htmlSignature != null && htmlSignature.isNotEmpty) {
|
||||
publicAssetController?.getOldPublicAssetFromHtmlContent(htmlSignature);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,6 +401,8 @@ class IdentityCreatorController extends BaseController with DragDropFileMixin {
|
||||
listDefaultIdentityIds?.contains(identity?.id) == true
|
||||
) {
|
||||
isDefaultIdentity.value = true;
|
||||
} else if (arguments?.isDefault == true) {
|
||||
isDefaultIdentity.value = true;
|
||||
} else {
|
||||
isDefaultIdentity.value = false;
|
||||
}
|
||||
@@ -438,6 +463,30 @@ class IdentityCreatorController extends BaseController with DragDropFileMixin {
|
||||
return;
|
||||
}
|
||||
|
||||
final identityAndPublicAssetArguments = await _generateIdentityAndPublicAssetArguments();
|
||||
|
||||
if (actionType.value == IdentityActionType.create) {
|
||||
final generateCreateId = Id(uuid.v1());
|
||||
final identityRequest = CreateNewIdentityRequest(
|
||||
generateCreateId,
|
||||
identityAndPublicAssetArguments.identity,
|
||||
publicAssetsInIdentityArguments: identityAndPublicAssetArguments.publicAssetsInIdentityArguments,
|
||||
isDefaultIdentity: isDefaultIdentity.value);
|
||||
popBack(result: identityRequest);
|
||||
} else {
|
||||
final identityRequest = EditIdentityRequest(
|
||||
identityId: identity!.id!,
|
||||
identityRequest: identityAndPublicAssetArguments.identity.toIdentityRequest(),
|
||||
publicAssetsInIdentityArguments: identityAndPublicAssetArguments.publicAssetsInIdentityArguments,
|
||||
isDefaultIdentity: isDefaultIdentity.value);
|
||||
popBack(result: identityRequest);
|
||||
}
|
||||
}
|
||||
|
||||
Future<({
|
||||
Identity identity,
|
||||
PublicAssetsInIdentityArguments publicAssetsInIdentityArguments
|
||||
})> _generateIdentityAndPublicAssetArguments() async {
|
||||
final signatureHtmlText = PlatformInfo.isWeb
|
||||
? contentHtmlEditor
|
||||
: await _getSignatureHtmlText();
|
||||
@@ -466,23 +515,10 @@ class IdentityCreatorController extends BaseController with DragDropFileMixin {
|
||||
htmlSignature: Signature(signatureHtmlText),
|
||||
sortOrder: sortOrder);
|
||||
|
||||
final generateCreateId = Id(uuid.v1());
|
||||
|
||||
if (actionType.value == IdentityActionType.create) {
|
||||
final identityRequest = CreateNewIdentityRequest(
|
||||
generateCreateId,
|
||||
newIdentity,
|
||||
publicAssetsInIdentityArguments: publicAssetsInIdentityArguments,
|
||||
isDefaultIdentity: isDefaultIdentity.value);
|
||||
popBack(result: identityRequest);
|
||||
} else {
|
||||
final identityRequest = EditIdentityRequest(
|
||||
identityId: identity!.id!,
|
||||
identityRequest: newIdentity.toIdentityRequest(),
|
||||
publicAssetsInIdentityArguments: publicAssetsInIdentityArguments,
|
||||
isDefaultIdentity: isDefaultIdentity.value);
|
||||
popBack(result: identityRequest);
|
||||
}
|
||||
return (
|
||||
identity: newIdentity,
|
||||
publicAssetsInIdentityArguments: publicAssetsInIdentityArguments
|
||||
);
|
||||
}
|
||||
|
||||
void onCheckboxChanged() {
|
||||
@@ -872,4 +908,34 @@ class IdentityCreatorController extends BaseController with DragDropFileMixin {
|
||||
logError("IdentityCreatorController::_uploadMultipleFilesToPublicAsset: error: $e");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onBeforeUnloadBrowserListener(html.Event event) async {
|
||||
if (event is html.BeforeUnloadEvent) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onUnloadBrowserListener(html.Event event) => _saveIdentityCacheOnWebAction();
|
||||
|
||||
@override
|
||||
Future<void> onBeforeReconnect() => _saveIdentityCacheOnWebAction();
|
||||
|
||||
Future<void> _saveIdentityCacheOnWebAction() async {
|
||||
if (accountId != null && session?.username != null) {
|
||||
final cacheArguments = await _generateIdentityAndPublicAssetArguments();
|
||||
final identityCache = IdentityCache(
|
||||
identity: cacheArguments.identity,
|
||||
identityActionType: actionType.value,
|
||||
isDefault: isDefaultIdentity.value,
|
||||
publicAssetsInIdentityArguments: cacheArguments.publicAssetsInIdentityArguments);
|
||||
|
||||
consumeState(_saveIdentityCacheOnWebInteractor.execute(
|
||||
accountId!,
|
||||
session!.username,
|
||||
identityCache: identityCache
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,14 @@ import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/identity_action_type.dart';
|
||||
import 'package:tmail_ui_user/features/public_asset/domain/model/public_assets_in_identity_arguments.dart';
|
||||
|
||||
class IdentityCreatorArguments with EquatableMixin {
|
||||
final AccountId accountId;
|
||||
final Session session;
|
||||
final IdentityActionType actionType;
|
||||
final PublicAssetsInIdentityArguments? publicAssetsInIdentityArguments;
|
||||
final bool? isDefault;
|
||||
final Identity? identity;
|
||||
|
||||
IdentityCreatorArguments(
|
||||
@@ -16,6 +19,8 @@ class IdentityCreatorArguments with EquatableMixin {
|
||||
this.session,
|
||||
{
|
||||
this.identity,
|
||||
this.publicAssetsInIdentityArguments,
|
||||
this.isDefault,
|
||||
this.actionType = IdentityActionType.create
|
||||
}
|
||||
);
|
||||
@@ -25,5 +30,7 @@ class IdentityCreatorArguments with EquatableMixin {
|
||||
accountId,
|
||||
session,
|
||||
identity,
|
||||
publicAssetsInIdentityArguments,
|
||||
isDefault,
|
||||
actionType];
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import 'package:jmap_dart_client/http/converter/id_converter.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:tmail_ui_user/features/public_asset/domain/model/public_assets_in_identity_arguments.dart';
|
||||
|
||||
part 'public_assets_in_identity_arguments_model.g.dart';
|
||||
|
||||
@JsonSerializable(converters: [IdConverter()])
|
||||
class PublicAssetsInIdentityArgumentsModel extends PublicAssetsInIdentityArguments {
|
||||
PublicAssetsInIdentityArgumentsModel({
|
||||
required super.htmlSignature,
|
||||
required super.preExistingPublicAssetIds,
|
||||
required super.newlyPickedPublicAssetIds});
|
||||
|
||||
factory PublicAssetsInIdentityArgumentsModel.fromJson(Map<String, dynamic> json)
|
||||
=> _$PublicAssetsInIdentityArgumentsModelFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$PublicAssetsInIdentityArgumentsModelToJson(this);
|
||||
|
||||
factory PublicAssetsInIdentityArgumentsModel.fromDomain(
|
||||
PublicAssetsInIdentityArguments publicAssetsInIdentityArguments
|
||||
) {
|
||||
return PublicAssetsInIdentityArgumentsModel(
|
||||
htmlSignature: publicAssetsInIdentityArguments.htmlSignature,
|
||||
preExistingPublicAssetIds: publicAssetsInIdentityArguments.preExistingPublicAssetIds,
|
||||
newlyPickedPublicAssetIds: publicAssetsInIdentityArguments.newlyPickedPublicAssetIds
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -173,6 +173,14 @@ class PublicAssetController extends BaseController {
|
||||
preExistingPublicAssetIds = htmlContent.publicAssetIdsFromHtmlContent;
|
||||
}
|
||||
|
||||
void restorePreExistingPublicAssetsFromCache(List<PublicAssetId> publicAssetIds) {
|
||||
preExistingPublicAssetIds = publicAssetIds;
|
||||
}
|
||||
|
||||
void restoreNewlyPickedPublicAssetsFromCache(List<PublicAssetId> publicAssetIds) {
|
||||
newlyPickedPublicAssetIds = publicAssetIds;
|
||||
}
|
||||
|
||||
void uploadFileToBlob(PlatformFile platformFile) {
|
||||
isUploading.value = true;
|
||||
_uploadFileToBlobAction(platformFile);
|
||||
|
||||
Reference in New Issue
Block a user