Skip to content

Commit

Permalink
fixup! TF-2901 Implement getting cache composer on log in
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora committed Jun 21, 2024
1 parent 437444f commit 2c59628
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:dartz/dartz.dart';
import 'package:flutter/material.dart';
import 'package:tmail_ui_user/features/base/widget/circle_loading_widget.dart';
import 'package:tmail_ui_user/features/composer/domain/state/download_image_as_base64_state.dart';
import 'package:tmail_ui_user/features/composer/domain/state/restore_email_inline_images_state.dart';
import 'package:tmail_ui_user/features/upload/domain/state/attachment_upload_state.dart';

class InsertImageLoadingBarWidget extends StatelessWidget {
Expand All @@ -22,32 +23,27 @@ class InsertImageLoadingBarWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return uploadInlineViewState.fold(
(failure) {
return viewState.fold(
(failure) => const SizedBox.shrink(),
(success) {
if (success is DownloadingImageAsBase64) {
return CircleLoadingWidget(padding: padding);
} else {
return const SizedBox.shrink();
}
}
);
},
(failure) => _viewStateToUI(viewState),
(success) {
if (success is UploadingAttachmentUploadState) {
return CircleLoadingWidget(padding: padding);
} else {
return viewState.fold(
(failure) => const SizedBox.shrink(),
(success) {
if (success is DownloadingImageAsBase64) {
return CircleLoadingWidget(padding: padding);
} else {
return const SizedBox.shrink();
}
}
);
return _viewStateToUI(viewState);
}
}
);
}

Widget _viewStateToUI(Either<Failure, Success> viewState) {
return viewState.fold(
(failure) => const SizedBox.shrink(),
(success) {
if (success is DownloadingImageAsBase64 ||
success is RestoringEmailInlineImages
) {
return CircleLoadingWidget(padding: padding);
} else {
return const SizedBox.shrink();
}
}
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:core/data/model/source_type/data_source_type.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/utils/html_transformer/html_transform.dart';
import 'package:core/utils/config/app_config_loader.dart';
import 'package:core/utils/file_utils.dart';
import 'package:core/utils/print_utils.dart';
Expand Down Expand Up @@ -233,6 +234,7 @@ class MailboxDashBoardBindings extends BaseBindings {
Get.find<MailboxCacheManager>(),
Get.find<CacheExceptionThrower>()));
Get.lazyPut(() => SessionStorageComposerDatasourceImpl(
Get.find<HtmlTransform>(),
Get.find<CacheExceptionThrower>()));
Get.lazyPut(() => SpamReportDataSourceImpl(
Get.find<SpamReportApi>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ class MailboxDashBoardController extends ReloadableController {
_setUpComponentsFromSession(session);

if (PlatformInfo.isWeb) {
_handleComposerCache();
_restoreComposerCacheFromReload(session);
}

if (PlatformInfo.isMobile && !_notificationManager.isNotificationClickedOnTerminate) {
Expand Down Expand Up @@ -1302,10 +1302,24 @@ class MailboxDashBoardController extends ReloadableController {
_getRouteParameters();
_setUpComponentsFromSession(session);
if (PlatformInfo.isWeb) {
_handleComposerCache();
_restoreComposerCacheFromReload(session);
}
}

Future<void> _restoreComposerCacheFromReload(Session session) async {
if (accountId.value == null) return;
if (_identities?.isEmpty ?? true) {
_identities = (await _getAllIdentitiesInteractor
.execute(session, accountId.value!).last)
.fold(
(failure) => <Identity>[],
(success) => success is GetAllIdentitiesSuccess
? success.identities ?? <Identity>[]
: <Identity>[]);
}
_handleComposerCache();
}

void _getRouteParameters() {
final parameters = Get.parameters;
log('MailboxDashBoardController::_getRouteParameters(): parameters: $parameters');
Expand Down Expand Up @@ -1407,7 +1421,9 @@ class MailboxDashBoardController extends ReloadableController {
}

void goToComposer(ComposerArguments arguments) async {
final argumentsWithIdentity = arguments.withIdentity(identities: List.from(_identities ?? []));
final argumentsWithIdentity = arguments.withIdentity(
identities: List.from(_identities ?? []),
selectedIdentity: arguments.selectedIdentity);

if (PlatformInfo.isWeb) {
if (composerOverlayState.value == ComposerOverlayState.inActive) {
Expand Down

0 comments on commit 2c59628

Please sign in to comment.