Skip to content

Commit

Permalink
TF-2143 Handle open composer into new tab when have `Attachments/Inli…
Browse files Browse the repository at this point in the history
…neImages/ReadRecipient/Signature`
  • Loading branch information
dab246 committed Jul 9, 2024
1 parent 5bb9d58 commit 88dea2a
Show file tree
Hide file tree
Showing 52 changed files with 636 additions and 628 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class ComposerRepositoryImpl extends ComposerRepository {
if (createEmailRequest.inlineAttachments?.isNotEmpty == true) {
final tupleContentInlineAttachments = await _replaceImageBase64ToImageCID(
emailContent: emailContent,
inlineAttachments: createEmailRequest.inlineAttachments!
inlineAttachments: createEmailRequest.inlineAttachments!,
isCaching: createEmailRequest.isCaching
);

emailContent = tupleContentInlineAttachments.value1;
Expand All @@ -77,12 +78,14 @@ class ComposerRepositoryImpl extends ComposerRepository {

Future<Tuple2<String, Set<EmailBodyPart>>> _replaceImageBase64ToImageCID({
required String emailContent,
required Map<String, Attachment> inlineAttachments
required Map<String, Attachment> inlineAttachments,
bool isCaching = false
}) {
try {
return _htmlDataSource.replaceImageBase64ToImageCID(
emailContent: emailContent,
inlineAttachments: inlineAttachments);
inlineAttachments: inlineAttachments,
isCaching: isCaching);
} catch (e) {
logError('ComposerRepositoryImpl::_replaceImageBase64ToImageCID: Exception: $e');
return Future.value(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import 'package:dartz/dartz.dart';
import 'package:tmail_ui_user/features/composer/domain/state/restore_email_inline_images_state.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/repository/composer_cache_repository.dart';

class RestoreEmailInlineImagesInteractor {
RestoreEmailInlineImagesInteractor(this._composerCacheRepository);
class ConvertImageCIDToBase46Interactor {
ConvertImageCIDToBase46Interactor(this._composerCacheRepository);

final ComposerCacheRepository _composerCacheRepository;

Expand All @@ -17,8 +17,7 @@ class RestoreEmailInlineImagesInteractor {
}) async* {
try {
yield Right(RestoringEmailInlineImages());

final emailContent = await _composerCacheRepository.restoreEmailInlineImages(
final emailContent = await _composerCacheRepository.convertImageCIDToBase64(
htmlContent,
transformConfiguration,
mapUrlDownloadCID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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/composer/domain/repository/composer_repository.dart';
import 'package:tmail_ui_user/features/composer/presentation/model/create_email_request.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';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/repository/composer_cache_repository.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/state/save_composer_cache_state.dart';

Expand All @@ -21,19 +21,20 @@ class SaveComposerCacheOnWebInteractor {
Future<Either<Failure, Success>> execute(
CreateEmailRequest createEmailRequest,
AccountId accountId,
UserName userName,
{required ScreenDisplayMode displayMode}
UserName userName
) async {
try {
final emailCreated = await _composerRepository.generateEmail(createEmailRequest);
final identity = createEmailRequest.identity;
final composerCache = ComposerCache(
email: emailCreated,
identity: createEmailRequest.identity,
isRequestReadReceipt: createEmailRequest.isRequestReadReceipt,
displayMode: createEmailRequest.displayMode,
);
await _composerCacheRepository.saveComposerCacheOnWeb(
emailCreated,
accountId: accountId,
userName: userName,
displayMode: displayMode,
identity: identity,
readReceipentEnabled: createEmailRequest.isRequestReadReceipt);
composerCache,
accountId,
userName);
return Right(SaveComposerCacheSuccess());
} catch (exception) {
return Left(SaveComposerCacheFailure(exception));
Expand Down
10 changes: 5 additions & 5 deletions lib/features/composer/presentation/composer_bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import 'package:tmail_ui_user/features/composer/data/repository/composer_reposit
import 'package:tmail_ui_user/features/composer/data/repository/contact_repository_impl.dart';
import 'package:tmail_ui_user/features/composer/domain/repository/composer_repository.dart';
import 'package:tmail_ui_user/features/composer/domain/repository/contact_repository.dart';
import 'package:tmail_ui_user/features/composer/domain/usecases/convert_image_cid_to_base64_interactor.dart';
import 'package:tmail_ui_user/features/composer/domain/usecases/create_new_and_save_email_to_drafts_interactor.dart';
import 'package:tmail_ui_user/features/composer/domain/usecases/create_new_and_send_email_interactor.dart';
import 'package:tmail_ui_user/features/composer/domain/usecases/download_image_as_base64_interactor.dart';
import 'package:tmail_ui_user/features/composer/domain/usecases/restore_email_inline_images_interactor.dart';
import 'package:tmail_ui_user/features/composer/domain/usecases/save_composer_cache_on_web_interactor.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/usecases/store_composed_email_to_local_storage_browser_interactor.dart';
import 'package:tmail_ui_user/features/composer/domain/usecases/upload_attachment_interactor.dart';
import 'package:tmail_ui_user/features/composer/presentation/composer_controller.dart';
import 'package:tmail_ui_user/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart';
Expand Down Expand Up @@ -46,6 +45,7 @@ import 'package:tmail_ui_user/features/mailbox/data/repository/mailbox_repositor
import 'package:tmail_ui_user/features/mailbox/domain/repository/mailbox_repository.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/repository/composer_cache_repository.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/usecases/remove_composer_cache_on_web_interactor.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/usecases/save_composer_cache_to_local_storage_browser_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/offline_mode/manager/new_email_cache_manager.dart';
Expand Down Expand Up @@ -210,9 +210,9 @@ class ComposerBindings extends BaseBindings {
Get.find<MailboxRepository>(),
Get.find<ComposerRepository>(),
));
Get.lazyPut(() => RestoreEmailInlineImagesInteractor(
Get.lazyPut(() => ConvertImageCIDToBase46Interactor(
Get.find<ComposerCacheRepository>()));
Get.lazyPut(() => StoreComposedEmailToLocalStorageBrowserInteractor(
Get.lazyPut(() => SaveComposerCacheToLocalStorageBrowserInteractor(
Get.find<ComposerCacheRepository>(),
Get.find<ComposerRepository>(),
));
Expand Down Expand Up @@ -241,7 +241,7 @@ class ComposerBindings extends BaseBindings {
Get.find<GetAlwaysReadReceiptSettingInteractor>(),
Get.find<CreateNewAndSendEmailInteractor>(),
Get.find<CreateNewAndSaveEmailToDraftsInteractor>(),
Get.find<StoreComposedEmailToLocalStorageBrowserInteractor>(),
Get.find<SaveComposerCacheToLocalStorageBrowserInteractor>(),
));
}

Expand Down
Loading

0 comments on commit 88dea2a

Please sign in to comment.