TF-2667 Add cancel button in progress saving message to drafts dialog
This commit is contained in:
@@ -25,14 +25,12 @@ class ApplicationManager {
|
|||||||
|
|
||||||
Future<String> getUserAgent() async {
|
Future<String> getUserAgent() async {
|
||||||
try {
|
try {
|
||||||
String userAgent;
|
String userAgent = '';
|
||||||
if (PlatformInfo.isWeb) {
|
if (PlatformInfo.isWeb) {
|
||||||
final webBrowserInfo = await _deviceInfoPlugin.webBrowserInfo;
|
final webBrowserInfo = await _deviceInfoPlugin.webBrowserInfo;
|
||||||
userAgent = webBrowserInfo.userAgent ?? '';
|
userAgent = webBrowserInfo.userAgent ?? '';
|
||||||
} else {
|
} else if (PlatformInfo.isMobile) {
|
||||||
await FkUserAgent.init();
|
|
||||||
userAgent = FkUserAgent.userAgent ?? '';
|
userAgent = FkUserAgent.userAgent ?? '';
|
||||||
FkUserAgent.release();
|
|
||||||
}
|
}
|
||||||
log('ApplicationManager::getUserAgent: $userAgent');
|
log('ApplicationManager::getUserAgent: $userAgent');
|
||||||
return userAgent;
|
return userAgent;
|
||||||
@@ -42,9 +40,21 @@ class ApplicationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> initUserAgent() async {
|
||||||
|
if (PlatformInfo.isMobile) {
|
||||||
|
await FkUserAgent.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> releaseUserAgent() async {
|
||||||
|
if (PlatformInfo.isMobile) {
|
||||||
|
FkUserAgent.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<String> generateApplicationUserAgent() async {
|
Future<String> generateApplicationUserAgent() async {
|
||||||
final userAgent = await getUserAgent();
|
final userAgent = await getUserAgent();
|
||||||
final version = await getVersion();
|
final version = await getVersion();
|
||||||
return 'Team-Mail/$version $userAgent';
|
return 'Twake-Mail/$version $userAgent';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1 +1,3 @@
|
|||||||
class SendingEmailCanceledException implements Exception {}
|
class SendingEmailCanceledException implements Exception {}
|
||||||
|
|
||||||
|
class SavingEmailToDraftsCanceledException implements Exception {}
|
||||||
@@ -25,4 +25,6 @@ class SaveEmailAsDraftsSuccess extends UIActionState {
|
|||||||
class SaveEmailAsDraftsFailure extends FeatureFailure {
|
class SaveEmailAsDraftsFailure extends FeatureFailure {
|
||||||
|
|
||||||
SaveEmailAsDraftsFailure(dynamic exception) : super(exception: exception);
|
SaveEmailAsDraftsFailure(dynamic exception) : super(exception: exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CancelSavingEmailToDrafts extends LoadingState {}
|
||||||
+28
-9
@@ -2,10 +2,12 @@ import 'package:core/presentation/state/failure.dart';
|
|||||||
import 'package:core/presentation/state/success.dart';
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:dartz/dartz.dart' as dartz;
|
import 'package:dartz/dartz.dart' as dartz;
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
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/core/session/session.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/domain/exceptions/compose_email_exception.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/domain/repository/composer_repository.dart';
|
import 'package:tmail_ui_user/features/composer/domain/repository/composer_repository.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/domain/state/generate_email_state.dart';
|
import 'package:tmail_ui_user/features/composer/domain/state/generate_email_state.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/domain/state/save_email_as_drafts_state.dart';
|
import 'package:tmail_ui_user/features/composer/domain/state/save_email_as_drafts_state.dart';
|
||||||
@@ -14,6 +16,7 @@ import 'package:tmail_ui_user/features/composer/presentation/model/create_email_
|
|||||||
import 'package:tmail_ui_user/features/email/domain/exceptions/email_exceptions.dart';
|
import 'package:tmail_ui_user/features/email/domain/exceptions/email_exceptions.dart';
|
||||||
import 'package:tmail_ui_user/features/email/domain/repository/email_repository.dart';
|
import 'package:tmail_ui_user/features/email/domain/repository/email_repository.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/domain/repository/mailbox_repository.dart';
|
import 'package:tmail_ui_user/features/mailbox/domain/repository/mailbox_repository.dart';
|
||||||
|
import 'package:tmail_ui_user/main/exceptions/remote_exception.dart';
|
||||||
|
|
||||||
class CreateNewAndSaveEmailToDraftsInteractor {
|
class CreateNewAndSaveEmailToDraftsInteractor {
|
||||||
final EmailRepository _emailRepository;
|
final EmailRepository _emailRepository;
|
||||||
@@ -26,7 +29,10 @@ class CreateNewAndSaveEmailToDraftsInteractor {
|
|||||||
this._composerRepository,
|
this._composerRepository,
|
||||||
);
|
);
|
||||||
|
|
||||||
Stream<dartz.Either<Failure, Success>> execute(CreateEmailRequest createEmailRequest) async* {
|
Stream<dartz.Either<Failure, Success>> execute({
|
||||||
|
required CreateEmailRequest createEmailRequest,
|
||||||
|
CancelToken? cancelToken,
|
||||||
|
}) async* {
|
||||||
try {
|
try {
|
||||||
yield dartz.Right<Failure, Success>(GenerateEmailLoading());
|
yield dartz.Right<Failure, Success>(GenerateEmailLoading());
|
||||||
|
|
||||||
@@ -44,7 +50,8 @@ class CreateNewAndSaveEmailToDraftsInteractor {
|
|||||||
final emailDraftSaved = await _emailRepository.saveEmailAsDrafts(
|
final emailDraftSaved = await _emailRepository.saveEmailAsDrafts(
|
||||||
createEmailRequest.session,
|
createEmailRequest.session,
|
||||||
createEmailRequest.accountId,
|
createEmailRequest.accountId,
|
||||||
emailCreated
|
emailCreated,
|
||||||
|
cancelToken: cancelToken
|
||||||
);
|
);
|
||||||
|
|
||||||
yield dartz.Right<Failure, Success>(
|
yield dartz.Right<Failure, Success>(
|
||||||
@@ -61,13 +68,15 @@ class CreateNewAndSaveEmailToDraftsInteractor {
|
|||||||
createEmailRequest.session,
|
createEmailRequest.session,
|
||||||
createEmailRequest.accountId,
|
createEmailRequest.accountId,
|
||||||
emailCreated,
|
emailCreated,
|
||||||
createEmailRequest.draftsEmailId!
|
createEmailRequest.draftsEmailId!,
|
||||||
|
cancelToken: cancelToken
|
||||||
);
|
);
|
||||||
|
|
||||||
await _deleteOldDraftsEmail(
|
await _deleteOldDraftsEmail(
|
||||||
session: createEmailRequest.session,
|
session: createEmailRequest.session,
|
||||||
accountId: createEmailRequest.accountId,
|
accountId: createEmailRequest.accountId,
|
||||||
draftEmailId: createEmailRequest.draftsEmailId!
|
draftEmailId: createEmailRequest.draftsEmailId!,
|
||||||
|
cancelToken: cancelToken
|
||||||
);
|
);
|
||||||
|
|
||||||
yield dartz.Right<Failure, Success>(
|
yield dartz.Right<Failure, Success>(
|
||||||
@@ -83,10 +92,18 @@ class CreateNewAndSaveEmailToDraftsInteractor {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logError('CreateNewAndSaveEmailToDraftsInteractor::execute: Exception: $e');
|
logError('CreateNewAndSaveEmailToDraftsInteractor::execute: Exception: $e');
|
||||||
if (createEmailRequest.draftsEmailId == null) {
|
if (e is UnknownError && e.message is List<SavingEmailToDraftsCanceledException>) {
|
||||||
yield dartz.Left<Failure, Success>(SaveEmailAsDraftsFailure(e));
|
if (createEmailRequest.draftsEmailId == null) {
|
||||||
|
yield dartz.Left<Failure, Success>(SaveEmailAsDraftsFailure(SavingEmailToDraftsCanceledException()));
|
||||||
|
} else {
|
||||||
|
yield dartz.Left<Failure, Success>(UpdateEmailDraftsFailure(SavingEmailToDraftsCanceledException()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
yield dartz.Left<Failure, Success>(UpdateEmailDraftsFailure(e));
|
if (createEmailRequest.draftsEmailId == null) {
|
||||||
|
yield dartz.Left<Failure, Success>(SaveEmailAsDraftsFailure(e));
|
||||||
|
} else {
|
||||||
|
yield dartz.Left<Failure, Success>(UpdateEmailDraftsFailure(e));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,13 +141,15 @@ class CreateNewAndSaveEmailToDraftsInteractor {
|
|||||||
Future<void> _deleteOldDraftsEmail({
|
Future<void> _deleteOldDraftsEmail({
|
||||||
required Session session,
|
required Session session,
|
||||||
required AccountId accountId,
|
required AccountId accountId,
|
||||||
required EmailId draftEmailId
|
required EmailId draftEmailId,
|
||||||
|
CancelToken? cancelToken
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
await _emailRepository.removeEmailDrafts(
|
await _emailRepository.removeEmailDrafts(
|
||||||
session,
|
session,
|
||||||
accountId,
|
accountId,
|
||||||
draftEmailId
|
draftEmailId,
|
||||||
|
cancelToken: cancelToken
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logError('CreateNewAndSaveEmailToDraftsInteractor::_deleteOldDraftsEmail: Exception: $e');
|
logError('CreateNewAndSaveEmailToDraftsInteractor::_deleteOldDraftsEmail: Exception: $e');
|
||||||
|
|||||||
@@ -1129,10 +1129,11 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final emailContent = await _getContentInEditor();
|
final emailContent = await _getContentInEditor();
|
||||||
|
final cancelToken = CancelToken();
|
||||||
final resultState = await _showSavingMessageToDraftsDialog(
|
final resultState = await _showSavingMessageToDraftsDialog(
|
||||||
emailContent: emailContent,
|
emailContent: emailContent,
|
||||||
draftEmailId: _emailIdEditing
|
draftEmailId: _emailIdEditing,
|
||||||
|
cancelToken: cancelToken
|
||||||
);
|
);
|
||||||
|
|
||||||
if (resultState is SaveEmailAsDraftsSuccess) {
|
if (resultState is SaveEmailAsDraftsSuccess) {
|
||||||
@@ -1143,6 +1144,9 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
|||||||
_saveToDraftButtonState = ButtonState.enabled;
|
_saveToDraftButtonState = ButtonState.enabled;
|
||||||
_emailIdEditing = resultState.emailId;
|
_emailIdEditing = resultState.emailId;
|
||||||
mailboxDashBoardController.consumeState(Stream.value(Right<Failure, Success>(resultState)));
|
mailboxDashBoardController.consumeState(Stream.value(Right<Failure, Success>(resultState)));
|
||||||
|
} else if ((resultState is SaveEmailAsDraftsFailure && resultState.exception is SavingEmailToDraftsCanceledException) ||
|
||||||
|
(resultState is UpdateEmailDraftsFailure && resultState.exception is SavingEmailToDraftsCanceledException)) {
|
||||||
|
_saveToDraftButtonState = ButtonState.enabled;
|
||||||
} else if ((resultState is SaveEmailAsDraftsFailure ||
|
} else if ((resultState is SaveEmailAsDraftsFailure ||
|
||||||
resultState is UpdateEmailDraftsFailure ||
|
resultState is UpdateEmailDraftsFailure ||
|
||||||
resultState is GenerateEmailFailure) &&
|
resultState is GenerateEmailFailure) &&
|
||||||
@@ -2035,14 +2039,20 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
|||||||
final emailContent = await _getContentInEditor();
|
final emailContent = await _getContentInEditor();
|
||||||
final draftEmailId = _getDraftEmailId();
|
final draftEmailId = _getDraftEmailId();
|
||||||
log('ComposerController::_handleSaveMessageToDraft: draftEmailId = $draftEmailId');
|
log('ComposerController::_handleSaveMessageToDraft: draftEmailId = $draftEmailId');
|
||||||
|
final cancelToken = CancelToken();
|
||||||
final resultState = await _showSavingMessageToDraftsDialog(
|
final resultState = await _showSavingMessageToDraftsDialog(
|
||||||
emailContent: emailContent,
|
emailContent: emailContent,
|
||||||
draftEmailId: draftEmailId
|
draftEmailId: draftEmailId,
|
||||||
|
cancelToken: cancelToken
|
||||||
);
|
);
|
||||||
|
|
||||||
if (resultState is SaveEmailAsDraftsSuccess || resultState is UpdateEmailDraftsSuccess) {
|
if (resultState is SaveEmailAsDraftsSuccess || resultState is UpdateEmailDraftsSuccess) {
|
||||||
_closeComposerButtonState = ButtonState.enabled;
|
_closeComposerButtonState = ButtonState.enabled;
|
||||||
_closeComposerAction(result: resultState);
|
_closeComposerAction(result: resultState);
|
||||||
|
} else if ((resultState is SaveEmailAsDraftsFailure && resultState.exception is SavingEmailToDraftsCanceledException) ||
|
||||||
|
(resultState is UpdateEmailDraftsFailure && resultState.exception is SavingEmailToDraftsCanceledException)) {
|
||||||
|
_closeComposerButtonState = ButtonState.enabled;
|
||||||
|
_closeComposerAction();
|
||||||
} else if ((resultState is SaveEmailAsDraftsFailure ||
|
} else if ((resultState is SaveEmailAsDraftsFailure ||
|
||||||
resultState is UpdateEmailDraftsFailure ||
|
resultState is UpdateEmailDraftsFailure ||
|
||||||
resultState is GenerateEmailFailure) &&
|
resultState is GenerateEmailFailure) &&
|
||||||
@@ -2071,6 +2081,7 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
|||||||
Future<dynamic> _showSavingMessageToDraftsDialog({
|
Future<dynamic> _showSavingMessageToDraftsDialog({
|
||||||
required String emailContent,
|
required String emailContent,
|
||||||
EmailId? draftEmailId,
|
EmailId? draftEmailId,
|
||||||
|
CancelToken? cancelToken,
|
||||||
}) {
|
}) {
|
||||||
return Get.dialog(
|
return Get.dialog(
|
||||||
PointerInterceptor(
|
PointerInterceptor(
|
||||||
@@ -2098,13 +2109,19 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
|||||||
references: composerArguments.value!.references,
|
references: composerArguments.value!.references,
|
||||||
emailSendingQueue: composerArguments.value!.sendingEmail
|
emailSendingQueue: composerArguments.value!.sendingEmail
|
||||||
),
|
),
|
||||||
createNewAndSaveEmailToDraftsInteractor: _createNewAndSaveEmailToDraftsInteractor
|
createNewAndSaveEmailToDraftsInteractor: _createNewAndSaveEmailToDraftsInteractor,
|
||||||
|
onCancelSavingEmailToDraftsAction: _handleCancelSavingMessageToDrafts,
|
||||||
|
cancelToken: cancelToken,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _handleCancelSavingMessageToDrafts({CancelToken? cancelToken}) {
|
||||||
|
cancelToken?.cancel([SavingEmailToDraftsCanceledException()]);
|
||||||
|
}
|
||||||
|
|
||||||
void _showConfirmDialogWhenSaveMessageToDraftsFailure({
|
void _showConfirmDialogWhenSaveMessageToDraftsFailure({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required FeatureFailure failure,
|
required FeatureFailure failure,
|
||||||
|
|||||||
@@ -5,27 +5,37 @@ import 'package:core/presentation/extensions/capitalize_extension.dart';
|
|||||||
import 'package:core/presentation/extensions/color_extension.dart';
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
import 'package:core/presentation/state/failure.dart';
|
import 'package:core/presentation/state/failure.dart';
|
||||||
import 'package:core/presentation/state/success.dart';
|
import 'package:core/presentation/state/success.dart';
|
||||||
|
import 'package:core/presentation/views/button/tmail_button_widget.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:dartz/dartz.dart' as dartz;
|
import 'package:dartz/dartz.dart' as dartz;
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/domain/exceptions/compose_email_exception.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/domain/state/generate_email_state.dart';
|
import 'package:tmail_ui_user/features/composer/domain/state/generate_email_state.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/domain/state/save_email_as_drafts_state.dart';
|
import 'package:tmail_ui_user/features/composer/domain/state/save_email_as_drafts_state.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/domain/state/update_email_drafts_state.dart';
|
import 'package:tmail_ui_user/features/composer/domain/state/update_email_drafts_state.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_save_email_to_drafts_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/presentation/model/create_email_request.dart';
|
import 'package:tmail_ui_user/features/composer/presentation/model/create_email_request.dart';
|
||||||
|
import 'package:tmail_ui_user/main/exceptions/remote_exception.dart';
|
||||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
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/routes/route_navigation.dart';
|
||||||
|
|
||||||
|
typedef OnCancelSavingEmailToDraftsAction = Function({CancelToken? cancelToken});
|
||||||
|
|
||||||
class SavingMessageDialogView extends StatefulWidget {
|
class SavingMessageDialogView extends StatefulWidget {
|
||||||
|
|
||||||
final CreateEmailRequest createEmailRequest;
|
final CreateEmailRequest createEmailRequest;
|
||||||
final CreateNewAndSaveEmailToDraftsInteractor createNewAndSaveEmailToDraftsInteractor;
|
final CreateNewAndSaveEmailToDraftsInteractor createNewAndSaveEmailToDraftsInteractor;
|
||||||
|
final OnCancelSavingEmailToDraftsAction? onCancelSavingEmailToDraftsAction;
|
||||||
|
final CancelToken? cancelToken;
|
||||||
|
|
||||||
const SavingMessageDialogView({
|
const SavingMessageDialogView({
|
||||||
super.key,
|
super.key,
|
||||||
required this.createEmailRequest,
|
required this.createEmailRequest,
|
||||||
required this.createNewAndSaveEmailToDraftsInteractor,
|
required this.createNewAndSaveEmailToDraftsInteractor,
|
||||||
|
this.onCancelSavingEmailToDraftsAction,
|
||||||
|
this.cancelToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -41,7 +51,10 @@ class _SavingMessageDialogViewState extends State<SavingMessageDialogView> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_streamSubscription = widget.createNewAndSaveEmailToDraftsInteractor
|
_streamSubscription = widget.createNewAndSaveEmailToDraftsInteractor
|
||||||
.execute(widget.createEmailRequest)
|
.execute(
|
||||||
|
createEmailRequest: widget.createEmailRequest,
|
||||||
|
cancelToken: widget.cancelToken
|
||||||
|
)
|
||||||
.listen(
|
.listen(
|
||||||
_handleDataStream,
|
_handleDataStream,
|
||||||
onError: _handleErrorStream
|
onError: _handleErrorStream
|
||||||
@@ -69,7 +82,11 @@ class _SavingMessageDialogViewState extends State<SavingMessageDialogView> {
|
|||||||
|
|
||||||
void _handleErrorStream(Object error, StackTrace stackTrace) {
|
void _handleErrorStream(Object error, StackTrace stackTrace) {
|
||||||
logError('_SavingMessageDialogViewState::_handleErrorStream: Exception = $error');
|
logError('_SavingMessageDialogViewState::_handleErrorStream: Exception = $error');
|
||||||
popBack(result: SaveEmailAsDraftsFailure(error));
|
if (error is UnknownError && error.message is List<SavingEmailToDraftsCanceledException>) {
|
||||||
|
popBack(result: SaveEmailAsDraftsFailure(SavingEmailToDraftsCanceledException()));
|
||||||
|
} else {
|
||||||
|
popBack(result: SaveEmailAsDraftsFailure(error));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -137,23 +154,13 @@ class _SavingMessageDialogViewState extends State<SavingMessageDialogView> {
|
|||||||
return value.fold(
|
return value.fold(
|
||||||
(failure) => child!,
|
(failure) => child!,
|
||||||
(success) {
|
(success) {
|
||||||
if (success is GenerateEmailLoading) {
|
return Text(
|
||||||
return Text(
|
'${_getStatusMessage(success)}...',
|
||||||
'${AppLocalizations.of(context).creatingMessage}...',
|
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||||
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
color: AppColor.labelColor,
|
||||||
color: AppColor.labelColor,
|
fontSize: 14
|
||||||
fontSize: 14
|
),
|
||||||
),
|
);
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return Text(
|
|
||||||
'${AppLocalizations.of(context).savingMessageToDraftFolder}...',
|
|
||||||
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
|
||||||
color: AppColor.labelColor,
|
|
||||||
fontSize: 14
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -170,7 +177,7 @@ class _SavingMessageDialogViewState extends State<SavingMessageDialogView> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsetsDirectional.only(start: 16, end: 16, top: 4, bottom: 24),
|
padding: const EdgeInsetsDirectional.only(start: 16, end: 16, top: 4, bottom: 16),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
@@ -191,7 +198,24 @@ class _SavingMessageDialogViewState extends State<SavingMessageDialogView> {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
|
if (widget.onCancelSavingEmailToDraftsAction != null)
|
||||||
|
Align(
|
||||||
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
|
child: TMailButtonWidget.fromText(
|
||||||
|
text: AppLocalizations.of(context).cancel,
|
||||||
|
textStyle: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||||
|
color: Colors.black87,
|
||||||
|
fontSize: 15
|
||||||
|
),
|
||||||
|
padding: const EdgeInsetsDirectional.symmetric(horizontal: 20, vertical: 8),
|
||||||
|
margin: const EdgeInsetsDirectional.only(start: 12, end: 12, bottom: 16),
|
||||||
|
onTapActionCallback: () {
|
||||||
|
_viewStateNotifier.value = dartz.Right<Failure, Success>(CancelSavingEmailToDrafts());
|
||||||
|
widget.onCancelSavingEmailToDraftsAction!(cancelToken: widget.cancelToken);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@@ -200,6 +224,16 @@ class _SavingMessageDialogViewState extends State<SavingMessageDialogView> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _getStatusMessage(Success success) {
|
||||||
|
if (success is GenerateEmailLoading) {
|
||||||
|
return AppLocalizations.of(context).creatingMessage;
|
||||||
|
} else if (success is CancelSavingEmailToDrafts) {
|
||||||
|
return AppLocalizations.of(context).canceling;
|
||||||
|
} else {
|
||||||
|
return AppLocalizations.of(context).savingMessageToDraftFolder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_streamSubscription?.cancel();
|
_streamSubscription?.cancel();
|
||||||
|
|||||||
@@ -151,31 +151,13 @@ class _SendingMessageDialogViewState extends State<SendingMessageDialogView> {
|
|||||||
return value.fold(
|
return value.fold(
|
||||||
(failure) => child!,
|
(failure) => child!,
|
||||||
(success) {
|
(success) {
|
||||||
if (success is GenerateEmailLoading) {
|
return Text(
|
||||||
return Text(
|
'${_getStatusMessage(success)}...',
|
||||||
'${AppLocalizations.of(context).creatingMessage}...',
|
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||||
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
color: AppColor.labelColor,
|
||||||
color: AppColor.labelColor,
|
fontSize: 14
|
||||||
fontSize: 14
|
),
|
||||||
),
|
);
|
||||||
);
|
|
||||||
} else if (success is CancelSendingEmail) {
|
|
||||||
return Text(
|
|
||||||
'${AppLocalizations.of(context).canceling}...',
|
|
||||||
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
|
||||||
color: AppColor.labelColor,
|
|
||||||
fontSize: 14
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return Text(
|
|
||||||
'${AppLocalizations.of(context).sendingMessage}...',
|
|
||||||
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
|
||||||
color: AppColor.labelColor,
|
|
||||||
fontSize: 14
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -239,6 +221,16 @@ class _SendingMessageDialogViewState extends State<SendingMessageDialogView> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _getStatusMessage(Success success) {
|
||||||
|
if (success is GenerateEmailLoading) {
|
||||||
|
return AppLocalizations.of(context).creatingMessage;
|
||||||
|
} else if (success is CancelSendingEmail) {
|
||||||
|
return AppLocalizations.of(context).canceling;
|
||||||
|
} else {
|
||||||
|
return AppLocalizations.of(context).sendingMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_streamSubscription?.cancel();
|
_streamSubscription?.cancel();
|
||||||
|
|||||||
@@ -74,11 +74,27 @@ abstract class EmailDataSource {
|
|||||||
MarkStarAction markStarAction
|
MarkStarAction markStarAction
|
||||||
);
|
);
|
||||||
|
|
||||||
Future<Email> saveEmailAsDrafts(Session session, AccountId accountId, Email email);
|
Future<Email> saveEmailAsDrafts(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
Email email,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
);
|
||||||
|
|
||||||
Future<bool> removeEmailDrafts(Session session, AccountId accountId, EmailId emailId);
|
Future<bool> removeEmailDrafts(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
EmailId emailId,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
);
|
||||||
|
|
||||||
Future<Email> updateEmailDrafts(Session session, AccountId accountId, Email newEmail, EmailId oldEmailId);
|
Future<Email> updateEmailDrafts(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
Email newEmail,
|
||||||
|
EmailId oldEmailId,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
);
|
||||||
|
|
||||||
Future<List<EmailId>> deleteMultipleEmailsPermanently(Session session, AccountId accountId, List<EmailId> emailIds);
|
Future<List<EmailId>> deleteMultipleEmailsPermanently(Session session, AccountId accountId, List<EmailId> emailIds);
|
||||||
|
|
||||||
|
|||||||
@@ -116,23 +116,55 @@ class EmailDataSourceImpl extends EmailDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Email> saveEmailAsDrafts(Session session, AccountId accountId, Email email) {
|
Future<Email> saveEmailAsDrafts(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
Email email,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
) {
|
||||||
return Future.sync(() async {
|
return Future.sync(() async {
|
||||||
return await emailAPI.saveEmailAsDrafts(session, accountId, email);
|
return await emailAPI.saveEmailAsDrafts(
|
||||||
|
session,
|
||||||
|
accountId,
|
||||||
|
email,
|
||||||
|
cancelToken: cancelToken
|
||||||
|
);
|
||||||
}).catchError(_exceptionThrower.throwException);
|
}).catchError(_exceptionThrower.throwException);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool> removeEmailDrafts(Session session, AccountId accountId, EmailId emailId) {
|
Future<bool> removeEmailDrafts(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
EmailId emailId,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
) {
|
||||||
return Future.sync(() async {
|
return Future.sync(() async {
|
||||||
return await emailAPI.removeEmailDrafts(session, accountId, emailId);
|
return await emailAPI.removeEmailDrafts(
|
||||||
|
session,
|
||||||
|
accountId,
|
||||||
|
emailId,
|
||||||
|
cancelToken: cancelToken
|
||||||
|
);
|
||||||
}).catchError(_exceptionThrower.throwException);
|
}).catchError(_exceptionThrower.throwException);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Email> updateEmailDrafts(Session session, AccountId accountId, Email newEmail, EmailId oldEmailId) {
|
Future<Email> updateEmailDrafts(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
Email newEmail,
|
||||||
|
EmailId oldEmailId,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
) {
|
||||||
return Future.sync(() async {
|
return Future.sync(() async {
|
||||||
return await emailAPI.updateEmailDrafts(session, accountId, newEmail, oldEmailId);
|
return await emailAPI.updateEmailDrafts(
|
||||||
|
session,
|
||||||
|
accountId,
|
||||||
|
newEmail,
|
||||||
|
oldEmailId,
|
||||||
|
cancelToken: cancelToken
|
||||||
|
);
|
||||||
}).catchError(_exceptionThrower.throwException);
|
}).catchError(_exceptionThrower.throwException);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,12 +129,22 @@ class EmailHiveCacheDataSourceImpl extends EmailDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool> removeEmailDrafts(Session session, AccountId accountId, EmailId emailId) {
|
Future<bool> removeEmailDrafts(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
EmailId emailId,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
) {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Email> saveEmailAsDrafts(Session session, AccountId accountId, Email email) {
|
Future<Email> saveEmailAsDrafts(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
Email email,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
) {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +188,13 @@ class EmailHiveCacheDataSourceImpl extends EmailDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Email> updateEmailDrafts(Session session, AccountId accountId, Email newEmail, EmailId oldEmailId) {
|
Future<Email> updateEmailDrafts(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
Email newEmail,
|
||||||
|
EmailId oldEmailId,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
) {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -479,7 +479,12 @@ class EmailAPI with HandleSetErrorMixin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Email> saveEmailAsDrafts(Session session, AccountId accountId, Email email) async {
|
Future<Email> saveEmailAsDrafts(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
Email email,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
) async {
|
||||||
final idCreateMethod = Id(_uuid.v1());
|
final idCreateMethod = Id(_uuid.v1());
|
||||||
final setEmailMethod = SetEmailMethod(accountId)
|
final setEmailMethod = SetEmailMethod(accountId)
|
||||||
..addCreate(idCreateMethod, email);
|
..addCreate(idCreateMethod, email);
|
||||||
@@ -494,7 +499,7 @@ class EmailAPI with HandleSetErrorMixin {
|
|||||||
final response = await (requestBuilder
|
final response = await (requestBuilder
|
||||||
..usings(capabilities))
|
..usings(capabilities))
|
||||||
.build()
|
.build()
|
||||||
.execute();
|
.execute(cancelToken: cancelToken);
|
||||||
|
|
||||||
final setEmailResponse = response.parse<SetEmailResponse>(
|
final setEmailResponse = response.parse<SetEmailResponse>(
|
||||||
setEmailInvocation.methodCallId,
|
setEmailInvocation.methodCallId,
|
||||||
@@ -511,7 +516,12 @@ class EmailAPI with HandleSetErrorMixin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> removeEmailDrafts(Session session, AccountId accountId, EmailId emailId) async {
|
Future<bool> removeEmailDrafts(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
EmailId emailId,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
) async {
|
||||||
final setEmailMethod = SetEmailMethod(accountId)
|
final setEmailMethod = SetEmailMethod(accountId)
|
||||||
..addDestroy({emailId.id});
|
..addDestroy({emailId.id});
|
||||||
|
|
||||||
@@ -525,7 +535,7 @@ class EmailAPI with HandleSetErrorMixin {
|
|||||||
final response = await (requestBuilder
|
final response = await (requestBuilder
|
||||||
..usings(capabilities))
|
..usings(capabilities))
|
||||||
.build()
|
.build()
|
||||||
.execute();
|
.execute(cancelToken: cancelToken);
|
||||||
|
|
||||||
final setEmailResponse = response.parse<SetEmailResponse>(
|
final setEmailResponse = response.parse<SetEmailResponse>(
|
||||||
setEmailInvocation.methodCallId,
|
setEmailInvocation.methodCallId,
|
||||||
@@ -542,7 +552,8 @@ class EmailAPI with HandleSetErrorMixin {
|
|||||||
Session session,
|
Session session,
|
||||||
AccountId accountId,
|
AccountId accountId,
|
||||||
Email newEmail,
|
Email newEmail,
|
||||||
EmailId oldEmailId
|
EmailId oldEmailId,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
) async {
|
) async {
|
||||||
final idCreateMethod = Id(_uuid.v1());
|
final idCreateMethod = Id(_uuid.v1());
|
||||||
final setEmailMethod = SetEmailMethod(accountId)
|
final setEmailMethod = SetEmailMethod(accountId)
|
||||||
@@ -559,7 +570,7 @@ class EmailAPI with HandleSetErrorMixin {
|
|||||||
final response = await (requestBuilder
|
final response = await (requestBuilder
|
||||||
..usings(capabilities))
|
..usings(capabilities))
|
||||||
.build()
|
.build()
|
||||||
.execute();
|
.execute(cancelToken: cancelToken);
|
||||||
|
|
||||||
final setEmailResponse = response.parse<SetEmailResponse>(
|
final setEmailResponse = response.parse<SetEmailResponse>(
|
||||||
setEmailInvocation.methodCallId,
|
setEmailInvocation.methodCallId,
|
||||||
|
|||||||
@@ -141,18 +141,50 @@ class EmailRepositoryImpl extends EmailRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Email> saveEmailAsDrafts(Session session, AccountId accountId, Email email) {
|
Future<Email> saveEmailAsDrafts(
|
||||||
return emailDataSource[DataSourceType.network]!.saveEmailAsDrafts(session, accountId, email);
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
Email email,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
) {
|
||||||
|
return emailDataSource[DataSourceType.network]!.saveEmailAsDrafts(
|
||||||
|
session,
|
||||||
|
accountId,
|
||||||
|
email,
|
||||||
|
cancelToken: cancelToken
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool> removeEmailDrafts(Session session, AccountId accountId, EmailId emailId) {
|
Future<bool> removeEmailDrafts(
|
||||||
return emailDataSource[DataSourceType.network]!.removeEmailDrafts(session, accountId, emailId);
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
EmailId emailId,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
) {
|
||||||
|
return emailDataSource[DataSourceType.network]!.removeEmailDrafts(
|
||||||
|
session,
|
||||||
|
accountId,
|
||||||
|
emailId,
|
||||||
|
cancelToken: cancelToken
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Email> updateEmailDrafts(Session session, AccountId accountId, Email newEmail, EmailId oldEmailId) {
|
Future<Email> updateEmailDrafts(
|
||||||
return emailDataSource[DataSourceType.network]!.updateEmailDrafts(session, accountId, newEmail, oldEmailId);
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
Email newEmail,
|
||||||
|
EmailId oldEmailId,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
) {
|
||||||
|
return emailDataSource[DataSourceType.network]!.updateEmailDrafts(
|
||||||
|
session,
|
||||||
|
accountId,
|
||||||
|
newEmail,
|
||||||
|
oldEmailId,
|
||||||
|
cancelToken: cancelToken
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -82,11 +82,27 @@ abstract class EmailRepository {
|
|||||||
TransformConfiguration transformConfiguration
|
TransformConfiguration transformConfiguration
|
||||||
);
|
);
|
||||||
|
|
||||||
Future<Email> saveEmailAsDrafts(Session session, AccountId accountId, Email email);
|
Future<Email> saveEmailAsDrafts(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
Email email,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
);
|
||||||
|
|
||||||
Future<bool> removeEmailDrafts(Session session, AccountId accountId, EmailId emailId);
|
Future<bool> removeEmailDrafts(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
EmailId emailId,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
);
|
||||||
|
|
||||||
Future<Email> updateEmailDrafts(Session session, AccountId accountId, Email newEmail, EmailId oldEmailId);
|
Future<Email> updateEmailDrafts(
|
||||||
|
Session session,
|
||||||
|
AccountId accountId,
|
||||||
|
Email newEmail,
|
||||||
|
EmailId oldEmailId,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
);
|
||||||
|
|
||||||
Future<List<EmailId>> deleteMultipleEmailsPermanently(Session session, AccountId accountId, List<EmailId> emailIds);
|
Future<List<EmailId>> deleteMultipleEmailsPermanently(Session session, AccountId accountId, List<EmailId> emailIds);
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -260,9 +260,12 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() async {
|
||||||
_registerStreamListener();
|
_registerStreamListener();
|
||||||
BackButtonInterceptor.add(_onBackButtonInterceptor, name: AppRoutes.dashboard);
|
BackButtonInterceptor.add(_onBackButtonInterceptor, name: AppRoutes.dashboard);
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
|
await applicationManager.initUserAgent();
|
||||||
|
});
|
||||||
super.onInit();
|
super.onInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2466,6 +2469,7 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
_refreshActionEventController.close();
|
_refreshActionEventController.close();
|
||||||
_notificationManager.closeStream();
|
_notificationManager.closeStream();
|
||||||
_fcmService.closeStream();
|
_fcmService.closeStream();
|
||||||
|
applicationManager.releaseUserAgent();
|
||||||
BackButtonInterceptor.removeByName(AppRoutes.dashboard);
|
BackButtonInterceptor.removeByName(AppRoutes.dashboard);
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user