TF-2188 Add Canceled sending state
(cherry picked from commit fb802e50dbdeaddabf09f450ad19a75ed7d27f39)
This commit is contained in:
+8
@@ -1838,6 +1838,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
EmailRequest emailRequest,
|
||||
CreateNewMailboxRequest? mailboxRequest,
|
||||
) {
|
||||
log('MailboxDashBoardController::_handleStoreSendingEmail:');
|
||||
final sendingEmail = emailRequest.toSendingEmail(_uuid.v1(), mailboxRequest: mailboxRequest);
|
||||
consumeState(_storeSendingEmailInteractor.execute(
|
||||
accountId,
|
||||
@@ -1852,6 +1853,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
EmailRequest emailRequest,
|
||||
CreateNewMailboxRequest? mailboxRequest,
|
||||
) {
|
||||
log('MailboxDashBoardController::_handleUpdateSendingEmail:');
|
||||
final storedSendingId = emailRequest.storedSendingId;
|
||||
if (storedSendingId != null) {
|
||||
final sendingEmail = emailRequest.toSendingEmail(storedSendingId, mailboxRequest: mailboxRequest);
|
||||
@@ -1862,6 +1864,12 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
));
|
||||
} else {
|
||||
logError('MailboxDashBoardController::_handleUpdateSendingEmail(): StoredSendingId is null');
|
||||
_handleStoreSendingEmail(
|
||||
session,
|
||||
accountId,
|
||||
emailRequest,
|
||||
mailboxRequest
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ enum SendingState {
|
||||
waiting,
|
||||
running,
|
||||
error,
|
||||
canceled,
|
||||
success;
|
||||
|
||||
String getTitle(BuildContext context) {
|
||||
@@ -16,6 +17,8 @@ enum SendingState {
|
||||
case SendingState.running:
|
||||
case SendingState.success:
|
||||
return AppLocalizations.of(context).delivering;
|
||||
case SendingState.canceled:
|
||||
return AppLocalizations.of(context).canceled;
|
||||
case SendingState.error:
|
||||
return AppLocalizations.of(context).error;
|
||||
}
|
||||
@@ -27,6 +30,8 @@ enum SendingState {
|
||||
case SendingState.running:
|
||||
case SendingState.success:
|
||||
return imagePaths.icDelivering;
|
||||
case SendingState.canceled:
|
||||
return imagePaths.icDelivering;
|
||||
case SendingState.error:
|
||||
return imagePaths.icError;
|
||||
}
|
||||
@@ -39,6 +44,7 @@ enum SendingState {
|
||||
case SendingState.waiting:
|
||||
case SendingState.error:
|
||||
case SendingState.success:
|
||||
case SendingState.canceled:
|
||||
return imagePaths.icAvatarGroup;
|
||||
}
|
||||
}
|
||||
@@ -50,6 +56,7 @@ enum SendingState {
|
||||
case SendingState.waiting:
|
||||
case SendingState.error:
|
||||
case SendingState.success:
|
||||
case SendingState.canceled:
|
||||
return imagePaths.icAvatarPersonal;
|
||||
}
|
||||
}
|
||||
@@ -59,6 +66,7 @@ enum SendingState {
|
||||
case SendingState.waiting:
|
||||
case SendingState.running:
|
||||
case SendingState.success:
|
||||
case SendingState.canceled:
|
||||
return AppColor.colorTitleSendingItem;
|
||||
case SendingState.error:
|
||||
return AppColor.colorErrorState;
|
||||
@@ -70,6 +78,7 @@ enum SendingState {
|
||||
case SendingState.waiting:
|
||||
case SendingState.running:
|
||||
case SendingState.success:
|
||||
case SendingState.canceled:
|
||||
return AppColor.colorBackgroundDeliveringState;
|
||||
case SendingState.error:
|
||||
return AppColor.colorBackgroundErrorState;
|
||||
@@ -83,6 +92,7 @@ enum SendingState {
|
||||
case SendingState.waiting:
|
||||
case SendingState.error:
|
||||
case SendingState.success:
|
||||
case SendingState.canceled:
|
||||
return Colors.black;
|
||||
}
|
||||
}
|
||||
@@ -94,6 +104,7 @@ enum SendingState {
|
||||
case SendingState.waiting:
|
||||
case SendingState.error:
|
||||
case SendingState.success:
|
||||
case SendingState.canceled:
|
||||
return AppColor.colorTitleSendingItem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class SendingEmailWorker extends Worker {
|
||||
failure is GetSessionFailure ||
|
||||
failure is GetStoredTokenOidcFailure ||
|
||||
failure is GetCredentialFailure) {
|
||||
_handleTaskFailureInWorkManager();
|
||||
_handleWorkerTaskToRetry();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ class SendingEmailWorker extends Worker {
|
||||
@override
|
||||
void handleOnError(Object? error, StackTrace stackTrace) {
|
||||
super.handleOnError(error, stackTrace);
|
||||
_handleTaskFailureInWorkManager();
|
||||
_handleWorkerTaskToRetry();
|
||||
}
|
||||
|
||||
void _getInteractorBindings() {
|
||||
@@ -155,7 +155,7 @@ class SendingEmailWorker extends Worker {
|
||||
_dynamicUrlInterceptors?.changeBaseUrl(apiUrl);
|
||||
_sendEmailAction(_currentAccountId!, _currentSession!);
|
||||
} else {
|
||||
_handleTaskFailureInWorkManager();
|
||||
_handleWorkerTaskToRetry();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,33 +202,34 @@ class SendingEmailWorker extends Worker {
|
||||
}
|
||||
|
||||
void _handleSendEmailSuccess(SendEmailSuccess success) {
|
||||
_updatingSendingStateToMainUI(sendingState: SendingState.success);
|
||||
_handleTaskSuccessInWorkManager();
|
||||
_handleWorkerTaskSuccess();
|
||||
}
|
||||
|
||||
void _handleSendEmailFailure(SendEmailFailure failure) {
|
||||
_updatingSendingStateToMainUI(sendingState: SendingState.error);
|
||||
_handleTaskErrorInWorkManager(failure.exception);
|
||||
_handleWorkerTaskFailure(failure.exception);
|
||||
}
|
||||
|
||||
void _handleTaskFailureInWorkManager() async {
|
||||
log('SendingEmailObserver::_handleTaskFailureInWorkManager():');
|
||||
void _handleWorkerTaskToRetry() async {
|
||||
_updatingSendingStateToMainUI(sendingState: SendingState.canceled);
|
||||
log('SendingEmailObserver::_handleWorkerTaskToRetry():');
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 1000),
|
||||
() => _completer.complete(false)
|
||||
);
|
||||
}
|
||||
|
||||
void _handleTaskErrorInWorkManager(dynamic error) async {
|
||||
log('SendingEmailObserver::_handleTaskErrorInWorkManager():');
|
||||
void _handleWorkerTaskFailure(dynamic error) async {
|
||||
log('SendingEmailObserver::_handleWorkerTaskFailure():error: $error');
|
||||
_updatingSendingStateToMainUI(sendingState: SendingState.error);
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 1000),
|
||||
() => _completer.completeError(error)
|
||||
);
|
||||
}
|
||||
|
||||
void _handleTaskSuccessInWorkManager() async {
|
||||
log('SendingEmailObserver::_handleTaskSuccessInWorkManager():');
|
||||
void _handleWorkerTaskSuccess() async {
|
||||
log('SendingEmailObserver::_handleWorkerTaskSuccess():');
|
||||
_updatingSendingStateToMainUI(sendingState: SendingState.success);
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 1000),
|
||||
() => _completer.complete(true)
|
||||
|
||||
@@ -105,6 +105,8 @@ class SendingEmail with EquatableMixin {
|
||||
|
||||
bool get isSuccess => sendingState == SendingState.success;
|
||||
|
||||
bool get isCanceled => sendingState == SendingState.canceled;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
sendingId,
|
||||
|
||||
@@ -124,17 +124,18 @@ class SendingQueueController extends BaseController with MessageDialogActionMixi
|
||||
dashboardController!.listSendingEmails.value = listSendingEmails;
|
||||
}
|
||||
break;
|
||||
case SendingState.canceled:
|
||||
case SendingState.error:
|
||||
if (accountId != null && userName != null) {
|
||||
final matchedSendingEmail = dashboardController?.listSendingEmails.firstWhereOrNull((sendingEmail) => sendingEmail.sendingId == sendingId);
|
||||
if (matchedSendingEmail != null) {
|
||||
_updateSendingEmailAction(
|
||||
newSendingEmail: matchedSendingEmail.updatingSendingState(SendingState.error),
|
||||
newSendingEmail: matchedSendingEmail.updatingSendingState(newState),
|
||||
accountId: accountId,
|
||||
userName: userName
|
||||
);
|
||||
} else {
|
||||
_getStoredSendingEmailAction(sendingId, accountId, userName, SendingState.error);
|
||||
_getStoredSendingEmailAction(sendingId, accountId, userName, newState);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"@@last_modified": "2023-10-02T15:04:12.165160",
|
||||
"@@last_modified": "2023-10-05T15:38:07.324902",
|
||||
"initializing_data": "Initializing data...",
|
||||
"@initializing_data": {
|
||||
"type": "text",
|
||||
@@ -3245,5 +3245,11 @@
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"canceled": "Canceled",
|
||||
"@canceled": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
}
|
||||
}
|
||||
@@ -3347,4 +3347,11 @@ class AppLocalizations {
|
||||
name: 'dropFileHereToAttachThem',
|
||||
);
|
||||
}
|
||||
|
||||
String get canceled {
|
||||
return Intl.message(
|
||||
'Canceled',
|
||||
name: 'canceled',
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user