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 {
|
||||
try {
|
||||
String userAgent;
|
||||
String userAgent = '';
|
||||
if (PlatformInfo.isWeb) {
|
||||
final webBrowserInfo = await _deviceInfoPlugin.webBrowserInfo;
|
||||
userAgent = webBrowserInfo.userAgent ?? '';
|
||||
} else {
|
||||
await FkUserAgent.init();
|
||||
} else if (PlatformInfo.isMobile) {
|
||||
userAgent = FkUserAgent.userAgent ?? '';
|
||||
FkUserAgent.release();
|
||||
}
|
||||
log('ApplicationManager::getUserAgent: $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 {
|
||||
final userAgent = await getUserAgent();
|
||||
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 {
|
||||
|
||||
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/utils/app_logger.dart';
|
||||
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/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.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/state/generate_email_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/repository/email_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 {
|
||||
final EmailRepository _emailRepository;
|
||||
@@ -26,7 +29,10 @@ class CreateNewAndSaveEmailToDraftsInteractor {
|
||||
this._composerRepository,
|
||||
);
|
||||
|
||||
Stream<dartz.Either<Failure, Success>> execute(CreateEmailRequest createEmailRequest) async* {
|
||||
Stream<dartz.Either<Failure, Success>> execute({
|
||||
required CreateEmailRequest createEmailRequest,
|
||||
CancelToken? cancelToken,
|
||||
}) async* {
|
||||
try {
|
||||
yield dartz.Right<Failure, Success>(GenerateEmailLoading());
|
||||
|
||||
@@ -44,7 +50,8 @@ class CreateNewAndSaveEmailToDraftsInteractor {
|
||||
final emailDraftSaved = await _emailRepository.saveEmailAsDrafts(
|
||||
createEmailRequest.session,
|
||||
createEmailRequest.accountId,
|
||||
emailCreated
|
||||
emailCreated,
|
||||
cancelToken: cancelToken
|
||||
);
|
||||
|
||||
yield dartz.Right<Failure, Success>(
|
||||
@@ -61,13 +68,15 @@ class CreateNewAndSaveEmailToDraftsInteractor {
|
||||
createEmailRequest.session,
|
||||
createEmailRequest.accountId,
|
||||
emailCreated,
|
||||
createEmailRequest.draftsEmailId!
|
||||
createEmailRequest.draftsEmailId!,
|
||||
cancelToken: cancelToken
|
||||
);
|
||||
|
||||
await _deleteOldDraftsEmail(
|
||||
session: createEmailRequest.session,
|
||||
accountId: createEmailRequest.accountId,
|
||||
draftEmailId: createEmailRequest.draftsEmailId!
|
||||
draftEmailId: createEmailRequest.draftsEmailId!,
|
||||
cancelToken: cancelToken
|
||||
);
|
||||
|
||||
yield dartz.Right<Failure, Success>(
|
||||
@@ -83,10 +92,18 @@ class CreateNewAndSaveEmailToDraftsInteractor {
|
||||
}
|
||||
} catch (e) {
|
||||
logError('CreateNewAndSaveEmailToDraftsInteractor::execute: Exception: $e');
|
||||
if (createEmailRequest.draftsEmailId == null) {
|
||||
yield dartz.Left<Failure, Success>(SaveEmailAsDraftsFailure(e));
|
||||
if (e is UnknownError && e.message is List<SavingEmailToDraftsCanceledException>) {
|
||||
if (createEmailRequest.draftsEmailId == null) {
|
||||
yield dartz.Left<Failure, Success>(SaveEmailAsDraftsFailure(SavingEmailToDraftsCanceledException()));
|
||||
} else {
|
||||
yield dartz.Left<Failure, Success>(UpdateEmailDraftsFailure(SavingEmailToDraftsCanceledException()));
|
||||
}
|
||||
} 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({
|
||||
required Session session,
|
||||
required AccountId accountId,
|
||||
required EmailId draftEmailId
|
||||
required EmailId draftEmailId,
|
||||
CancelToken? cancelToken
|
||||
}) async {
|
||||
try {
|
||||
await _emailRepository.removeEmailDrafts(
|
||||
session,
|
||||
accountId,
|
||||
draftEmailId
|
||||
draftEmailId,
|
||||
cancelToken: cancelToken
|
||||
);
|
||||
} catch (e) {
|
||||
logError('CreateNewAndSaveEmailToDraftsInteractor::_deleteOldDraftsEmail: Exception: $e');
|
||||
|
||||
@@ -1129,10 +1129,11 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
}
|
||||
|
||||
final emailContent = await _getContentInEditor();
|
||||
|
||||
final cancelToken = CancelToken();
|
||||
final resultState = await _showSavingMessageToDraftsDialog(
|
||||
emailContent: emailContent,
|
||||
draftEmailId: _emailIdEditing
|
||||
draftEmailId: _emailIdEditing,
|
||||
cancelToken: cancelToken
|
||||
);
|
||||
|
||||
if (resultState is SaveEmailAsDraftsSuccess) {
|
||||
@@ -1143,6 +1144,9 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
_saveToDraftButtonState = ButtonState.enabled;
|
||||
_emailIdEditing = resultState.emailId;
|
||||
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 ||
|
||||
resultState is UpdateEmailDraftsFailure ||
|
||||
resultState is GenerateEmailFailure) &&
|
||||
@@ -2035,14 +2039,20 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
final emailContent = await _getContentInEditor();
|
||||
final draftEmailId = _getDraftEmailId();
|
||||
log('ComposerController::_handleSaveMessageToDraft: draftEmailId = $draftEmailId');
|
||||
final cancelToken = CancelToken();
|
||||
final resultState = await _showSavingMessageToDraftsDialog(
|
||||
emailContent: emailContent,
|
||||
draftEmailId: draftEmailId
|
||||
draftEmailId: draftEmailId,
|
||||
cancelToken: cancelToken
|
||||
);
|
||||
|
||||
if (resultState is SaveEmailAsDraftsSuccess || resultState is UpdateEmailDraftsSuccess) {
|
||||
_closeComposerButtonState = ButtonState.enabled;
|
||||
_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 ||
|
||||
resultState is UpdateEmailDraftsFailure ||
|
||||
resultState is GenerateEmailFailure) &&
|
||||
@@ -2071,6 +2081,7 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
Future<dynamic> _showSavingMessageToDraftsDialog({
|
||||
required String emailContent,
|
||||
EmailId? draftEmailId,
|
||||
CancelToken? cancelToken,
|
||||
}) {
|
||||
return Get.dialog(
|
||||
PointerInterceptor(
|
||||
@@ -2098,13 +2109,19 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
||||
references: composerArguments.value!.references,
|
||||
emailSendingQueue: composerArguments.value!.sendingEmail
|
||||
),
|
||||
createNewAndSaveEmailToDraftsInteractor: _createNewAndSaveEmailToDraftsInteractor
|
||||
createNewAndSaveEmailToDraftsInteractor: _createNewAndSaveEmailToDraftsInteractor,
|
||||
onCancelSavingEmailToDraftsAction: _handleCancelSavingMessageToDrafts,
|
||||
cancelToken: cancelToken,
|
||||
),
|
||||
),
|
||||
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
||||
);
|
||||
}
|
||||
|
||||
void _handleCancelSavingMessageToDrafts({CancelToken? cancelToken}) {
|
||||
cancelToken?.cancel([SavingEmailToDraftsCanceledException()]);
|
||||
}
|
||||
|
||||
void _showConfirmDialogWhenSaveMessageToDraftsFailure({
|
||||
required BuildContext context,
|
||||
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/state/failure.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:dartz/dartz.dart' as dartz;
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.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/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/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/main/exceptions/remote_exception.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
typedef OnCancelSavingEmailToDraftsAction = Function({CancelToken? cancelToken});
|
||||
|
||||
class SavingMessageDialogView extends StatefulWidget {
|
||||
|
||||
final CreateEmailRequest createEmailRequest;
|
||||
final CreateNewAndSaveEmailToDraftsInteractor createNewAndSaveEmailToDraftsInteractor;
|
||||
final OnCancelSavingEmailToDraftsAction? onCancelSavingEmailToDraftsAction;
|
||||
final CancelToken? cancelToken;
|
||||
|
||||
const SavingMessageDialogView({
|
||||
super.key,
|
||||
required this.createEmailRequest,
|
||||
required this.createNewAndSaveEmailToDraftsInteractor,
|
||||
this.onCancelSavingEmailToDraftsAction,
|
||||
this.cancelToken,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -41,7 +51,10 @@ class _SavingMessageDialogViewState extends State<SavingMessageDialogView> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_streamSubscription = widget.createNewAndSaveEmailToDraftsInteractor
|
||||
.execute(widget.createEmailRequest)
|
||||
.execute(
|
||||
createEmailRequest: widget.createEmailRequest,
|
||||
cancelToken: widget.cancelToken
|
||||
)
|
||||
.listen(
|
||||
_handleDataStream,
|
||||
onError: _handleErrorStream
|
||||
@@ -69,7 +82,11 @@ class _SavingMessageDialogViewState extends State<SavingMessageDialogView> {
|
||||
|
||||
void _handleErrorStream(Object error, StackTrace stackTrace) {
|
||||
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
|
||||
@@ -137,23 +154,13 @@ class _SavingMessageDialogViewState extends State<SavingMessageDialogView> {
|
||||
return value.fold(
|
||||
(failure) => child!,
|
||||
(success) {
|
||||
if (success is GenerateEmailLoading) {
|
||||
return Text(
|
||||
'${AppLocalizations.of(context).creatingMessage}...',
|
||||
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||
color: AppColor.labelColor,
|
||||
fontSize: 14
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Text(
|
||||
'${AppLocalizations.of(context).savingMessageToDraftFolder}...',
|
||||
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||
color: AppColor.labelColor,
|
||||
fontSize: 14
|
||||
),
|
||||
);
|
||||
}
|
||||
return Text(
|
||||
'${_getStatusMessage(success)}...',
|
||||
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||
color: AppColor.labelColor,
|
||||
fontSize: 14
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
@@ -170,7 +177,7 @@ class _SavingMessageDialogViewState extends State<SavingMessageDialogView> {
|
||||
),
|
||||
),
|
||||
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(
|
||||
children: [
|
||||
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
|
||||
void dispose() {
|
||||
_streamSubscription?.cancel();
|
||||
|
||||
@@ -151,31 +151,13 @@ class _SendingMessageDialogViewState extends State<SendingMessageDialogView> {
|
||||
return value.fold(
|
||||
(failure) => child!,
|
||||
(success) {
|
||||
if (success is GenerateEmailLoading) {
|
||||
return Text(
|
||||
'${AppLocalizations.of(context).creatingMessage}...',
|
||||
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||
color: AppColor.labelColor,
|
||||
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
|
||||
),
|
||||
);
|
||||
}
|
||||
return Text(
|
||||
'${_getStatusMessage(success)}...',
|
||||
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
|
||||
void dispose() {
|
||||
_streamSubscription?.cancel();
|
||||
|
||||
@@ -74,11 +74,27 @@ abstract class EmailDataSource {
|
||||
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);
|
||||
|
||||
|
||||
@@ -116,23 +116,55 @@ class EmailDataSourceImpl extends EmailDataSource {
|
||||
}
|
||||
|
||||
@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 await emailAPI.saveEmailAsDrafts(session, accountId, email);
|
||||
return await emailAPI.saveEmailAsDrafts(
|
||||
session,
|
||||
accountId,
|
||||
email,
|
||||
cancelToken: cancelToken
|
||||
);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@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 await emailAPI.removeEmailDrafts(session, accountId, emailId);
|
||||
return await emailAPI.removeEmailDrafts(
|
||||
session,
|
||||
accountId,
|
||||
emailId,
|
||||
cancelToken: cancelToken
|
||||
);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@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 await emailAPI.updateEmailDrafts(session, accountId, newEmail, oldEmailId);
|
||||
return await emailAPI.updateEmailDrafts(
|
||||
session,
|
||||
accountId,
|
||||
newEmail,
|
||||
oldEmailId,
|
||||
cancelToken: cancelToken
|
||||
);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,12 +129,22 @@ class EmailHiveCacheDataSourceImpl extends EmailDataSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> removeEmailDrafts(Session session, AccountId accountId, EmailId emailId) {
|
||||
Future<bool> removeEmailDrafts(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
EmailId emailId,
|
||||
{CancelToken? cancelToken}
|
||||
) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Email> saveEmailAsDrafts(Session session, AccountId accountId, Email email) {
|
||||
Future<Email> saveEmailAsDrafts(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
Email email,
|
||||
{CancelToken? cancelToken}
|
||||
) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@@ -178,7 +188,13 @@ class EmailHiveCacheDataSourceImpl extends EmailDataSource {
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 setEmailMethod = SetEmailMethod(accountId)
|
||||
..addCreate(idCreateMethod, email);
|
||||
@@ -494,7 +499,7 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
final response = await (requestBuilder
|
||||
..usings(capabilities))
|
||||
.build()
|
||||
.execute();
|
||||
.execute(cancelToken: cancelToken);
|
||||
|
||||
final setEmailResponse = response.parse<SetEmailResponse>(
|
||||
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)
|
||||
..addDestroy({emailId.id});
|
||||
|
||||
@@ -525,7 +535,7 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
final response = await (requestBuilder
|
||||
..usings(capabilities))
|
||||
.build()
|
||||
.execute();
|
||||
.execute(cancelToken: cancelToken);
|
||||
|
||||
final setEmailResponse = response.parse<SetEmailResponse>(
|
||||
setEmailInvocation.methodCallId,
|
||||
@@ -542,7 +552,8 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
Email newEmail,
|
||||
EmailId oldEmailId
|
||||
EmailId oldEmailId,
|
||||
{CancelToken? cancelToken}
|
||||
) async {
|
||||
final idCreateMethod = Id(_uuid.v1());
|
||||
final setEmailMethod = SetEmailMethod(accountId)
|
||||
@@ -559,7 +570,7 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
final response = await (requestBuilder
|
||||
..usings(capabilities))
|
||||
.build()
|
||||
.execute();
|
||||
.execute(cancelToken: cancelToken);
|
||||
|
||||
final setEmailResponse = response.parse<SetEmailResponse>(
|
||||
setEmailInvocation.methodCallId,
|
||||
|
||||
@@ -141,18 +141,50 @@ class EmailRepositoryImpl extends EmailRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Email> saveEmailAsDrafts(Session session, AccountId accountId, Email email) {
|
||||
return emailDataSource[DataSourceType.network]!.saveEmailAsDrafts(session, accountId, email);
|
||||
Future<Email> saveEmailAsDrafts(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
Email email,
|
||||
{CancelToken? cancelToken}
|
||||
) {
|
||||
return emailDataSource[DataSourceType.network]!.saveEmailAsDrafts(
|
||||
session,
|
||||
accountId,
|
||||
email,
|
||||
cancelToken: cancelToken
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> removeEmailDrafts(Session session, AccountId accountId, EmailId emailId) {
|
||||
return emailDataSource[DataSourceType.network]!.removeEmailDrafts(session, accountId, emailId);
|
||||
Future<bool> removeEmailDrafts(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
EmailId emailId,
|
||||
{CancelToken? cancelToken}
|
||||
) {
|
||||
return emailDataSource[DataSourceType.network]!.removeEmailDrafts(
|
||||
session,
|
||||
accountId,
|
||||
emailId,
|
||||
cancelToken: cancelToken
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Email> updateEmailDrafts(Session session, AccountId accountId, Email newEmail, EmailId oldEmailId) {
|
||||
return emailDataSource[DataSourceType.network]!.updateEmailDrafts(session, accountId, newEmail, oldEmailId);
|
||||
Future<Email> updateEmailDrafts(
|
||||
Session session,
|
||||
AccountId accountId,
|
||||
Email newEmail,
|
||||
EmailId oldEmailId,
|
||||
{CancelToken? cancelToken}
|
||||
) {
|
||||
return emailDataSource[DataSourceType.network]!.updateEmailDrafts(
|
||||
session,
|
||||
accountId,
|
||||
newEmail,
|
||||
oldEmailId,
|
||||
cancelToken: cancelToken
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -82,11 +82,27 @@ abstract class EmailRepository {
|
||||
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);
|
||||
|
||||
|
||||
+5
-1
@@ -260,9 +260,12 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
);
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
void onInit() async {
|
||||
_registerStreamListener();
|
||||
BackButtonInterceptor.add(_onBackButtonInterceptor, name: AppRoutes.dashboard);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
await applicationManager.initUserAgent();
|
||||
});
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@@ -2466,6 +2469,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
_refreshActionEventController.close();
|
||||
_notificationManager.closeStream();
|
||||
_fcmService.closeStream();
|
||||
applicationManager.releaseUserAgent();
|
||||
BackButtonInterceptor.removeByName(AppRoutes.dashboard);
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user