TF-1613 Implement handleSuccessViewState and handleFailureViewState for all controller
(cherry picked from commit 35e727e795bb3c44cc9c47e02542b5bdc3955fdd)
This commit is contained in:
@@ -30,7 +30,11 @@ class AddTooltipLinkTransformer extends DomTransformer {
|
|||||||
if (children.isEmpty && text.isNotEmpty && url != null) {
|
if (children.isEmpty && text.isNotEmpty && url != null) {
|
||||||
final innerHtml = element.innerHtml;
|
final innerHtml = element.innerHtml;
|
||||||
final tagClass = element.attributes['class'];
|
final tagClass = element.attributes['class'];
|
||||||
element.attributes['class'] = '$tagClass $nameClassToolTip';
|
if (tagClass != null) {
|
||||||
|
element.attributes['class'] = '$tagClass $nameClassToolTip';
|
||||||
|
} else {
|
||||||
|
element.attributes['class'] = nameClassToolTip;
|
||||||
|
}
|
||||||
element.innerHtml = innerHtml + textHasToolTip(url);
|
element.innerHtml = innerHtml + textHasToolTip(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,20 +23,26 @@ class ImageTransformer extends DomTransformer {
|
|||||||
final imageElements = document.querySelectorAll('img[src^="cid:"]');
|
final imageElements = document.querySelectorAll('img[src^="cid:"]');
|
||||||
log('ImageTransformer::process(): imageElements: ${imageElements.length}');
|
log('ImageTransformer::process(): imageElements: ${imageElements.length}');
|
||||||
await Future.wait(imageElements.map((imageElement) async {
|
await Future.wait(imageElements.map((imageElement) async {
|
||||||
final _exStyle = imageElement.attributes['style'];
|
final exStyle = imageElement.attributes['style'];
|
||||||
imageElement.attributes['style'] = '$_exStyle display: inline;max-width: 100%;';
|
if (exStyle != null) {
|
||||||
|
imageElement.attributes['style'] = '$exStyle display: inline;max-width: 100%;';
|
||||||
|
} else {
|
||||||
|
imageElement.attributes['style'] = 'display: inline;max-width: 100%;';
|
||||||
|
}
|
||||||
final src = imageElement.attributes['src'];
|
final src = imageElement.attributes['src'];
|
||||||
log('ImageTransformer::process(): src: $src');
|
if (src != null) {
|
||||||
final cid = src?.replaceFirst('cid:', '').trim();
|
log('ImageTransformer::process(): src: $src');
|
||||||
final urlDownloadCid = mapUrlDownloadCID?[cid];
|
final cid = src.replaceFirst('cid:', '').trim();
|
||||||
log('ImageTransformer::process(): urlDownloadCid: $urlDownloadCid');
|
final urlDownloadCid = mapUrlDownloadCID?[cid];
|
||||||
if (urlDownloadCid?.isNotEmpty == true && dioClient != null) {
|
log('ImageTransformer::process(): urlDownloadCid: $urlDownloadCid');
|
||||||
final imgBase64Uri = await loadAsyncNetworkImageToBase64(
|
if (urlDownloadCid?.isNotEmpty == true && dioClient != null) {
|
||||||
|
final imgBase64Uri = await loadAsyncNetworkImageToBase64(
|
||||||
dioClient,
|
dioClient,
|
||||||
compressFileUtils,
|
compressFileUtils,
|
||||||
urlDownloadCid!);
|
urlDownloadCid!);
|
||||||
if (imgBase64Uri.isNotEmpty) {
|
if (imgBase64Uri.isNotEmpty) {
|
||||||
imageElement.attributes['src'] = imgBase64Uri;
|
imageElement.attributes['src'] = imgBase64Uri;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ abstract class BaseController extends GetxController
|
|||||||
viewState.value.fold(
|
viewState.value.fold(
|
||||||
(failure) {
|
(failure) {
|
||||||
if (_handleCommonException(failure)) {
|
if (_handleCommonException(failure)) {
|
||||||
|
handleFinallyCommonException();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handleFailureViewState(failure);
|
handleFailureViewState(failure);
|
||||||
@@ -113,6 +114,7 @@ abstract class BaseController extends GetxController
|
|||||||
void onError(Object error, StackTrace stackTrace) {
|
void onError(Object error, StackTrace stackTrace) {
|
||||||
logError('BaseController::onError():error: $error | stackTrace: $stackTrace');
|
logError('BaseController::onError():error: $error | stackTrace: $stackTrace');
|
||||||
if (_handleCommonError(error)) {
|
if (_handleCommonError(error)) {
|
||||||
|
handleFinallyCommonException();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handleErrorViewState(error, stackTrace);
|
handleErrorViewState(error, stackTrace);
|
||||||
@@ -142,7 +144,6 @@ abstract class BaseController extends GetxController
|
|||||||
currentOverlayContext!,
|
currentOverlayContext!,
|
||||||
AppLocalizations.of(currentContext!).badCredentials);
|
AppLocalizations.of(currentContext!).badCredentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkAuthenticationTypeWhenLogout();
|
checkAuthenticationTypeWhenLogout();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -152,6 +153,10 @@ abstract class BaseController extends GetxController
|
|||||||
|
|
||||||
void handleErrorViewState(Object error, StackTrace stackTrace) {}
|
void handleErrorViewState(Object error, StackTrace stackTrace) {}
|
||||||
|
|
||||||
|
void handleFinallyCommonException() {
|
||||||
|
clearState();
|
||||||
|
}
|
||||||
|
|
||||||
void handleFailureViewState(Failure failure) {
|
void handleFailureViewState(Failure failure) {
|
||||||
logError('BaseController::handleFailureViewState(): $failure');
|
logError('BaseController::handleFailureViewState(): $failure');
|
||||||
if (failure is LogoutOidcFailure) {
|
if (failure is LogoutOidcFailure) {
|
||||||
@@ -249,27 +254,18 @@ abstract class BaseController extends GetxController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fcmEnabled(Session? session, AccountId? accountId) {
|
bool _isFcmActivated(Session session, AccountId accountId) =>
|
||||||
bool fcmEnabled = false;
|
[FirebaseCapability.fcmIdentifier].isSupported(session, accountId) && AppConfig.fcmAvailable;
|
||||||
try {
|
|
||||||
requireCapability(session!, accountId!, [FirebaseCapability.fcmIdentifier]);
|
|
||||||
if (AppConfig.fcmAvailable) {
|
|
||||||
fcmEnabled = true;
|
|
||||||
} else {
|
|
||||||
fcmEnabled = false;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
logError('BaseController::fcmEnabled(): exception: $e');
|
|
||||||
}
|
|
||||||
return fcmEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void goToLogin({LoginArguments? arguments}) {
|
void goToLogin({LoginArguments? arguments}) {
|
||||||
pushAndPopAll(AppRoutes.login, arguments: arguments);
|
pushAndPopAll(AppRoutes.login, arguments: arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
void logout(Session? session, AccountId? accountId) {
|
void logout(Session? session, AccountId? accountId) {
|
||||||
_isFcmEnabled = fcmEnabled(session, accountId);
|
if (session == null || accountId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_isFcmEnabled = _isFcmActivated(session, accountId);
|
||||||
final authenticationType = authorizationInterceptors.authenticationType;
|
final authenticationType = authorizationInterceptors.authenticationType;
|
||||||
if (authenticationType == AuthenticationType.oidc) {
|
if (authenticationType == AuthenticationType.oidc) {
|
||||||
consumeState(logoutOidcInteractor.execute());
|
consumeState(logoutOidcInteractor.execute());
|
||||||
|
|||||||
@@ -112,9 +112,9 @@ abstract class BaseMailboxController extends BaseController {
|
|||||||
if (personalMailboxTree.value.updateExpandedNode(selectedMailboxNode, newExpandMode) != null) {
|
if (personalMailboxTree.value.updateExpandedNode(selectedMailboxNode, newExpandMode) != null) {
|
||||||
log('toggleMailboxFolder() refresh folderMailboxTree');
|
log('toggleMailboxFolder() refresh folderMailboxTree');
|
||||||
personalMailboxTree.refresh();
|
personalMailboxTree.refresh();
|
||||||
final _childrenItems = personalMailboxTree.value.root.childrenItems ?? [];
|
final childrenItems = personalMailboxTree.value.root.childrenItems ?? [];
|
||||||
_triggerScrollWhenExpandMailboxFolder(
|
_triggerScrollWhenExpandMailboxFolder(
|
||||||
_childrenItems,
|
childrenItems,
|
||||||
selectedMailboxNode,
|
selectedMailboxNode,
|
||||||
scrollController);
|
scrollController);
|
||||||
}
|
}
|
||||||
@@ -122,9 +122,9 @@ abstract class BaseMailboxController extends BaseController {
|
|||||||
if (teamMailboxesTree.value.updateExpandedNode(selectedMailboxNode, newExpandMode) != null) {
|
if (teamMailboxesTree.value.updateExpandedNode(selectedMailboxNode, newExpandMode) != null) {
|
||||||
log('toggleMailboxFolder() refresh teamMailboxesTree');
|
log('toggleMailboxFolder() refresh teamMailboxesTree');
|
||||||
teamMailboxesTree.refresh();
|
teamMailboxesTree.refresh();
|
||||||
final _childrenItems = teamMailboxesTree.value.root.childrenItems ?? [];
|
final childrenItems = teamMailboxesTree.value.root.childrenItems ?? [];
|
||||||
_triggerScrollWhenExpandMailboxFolder(
|
_triggerScrollWhenExpandMailboxFolder(
|
||||||
_childrenItems,
|
childrenItems,
|
||||||
selectedMailboxNode,
|
selectedMailboxNode,
|
||||||
scrollController);
|
scrollController);
|
||||||
}
|
}
|
||||||
@@ -135,13 +135,13 @@ abstract class BaseMailboxController extends BaseController {
|
|||||||
MailboxNode selectedMailboxNode,
|
MailboxNode selectedMailboxNode,
|
||||||
ScrollController scrollController) async {
|
ScrollController scrollController) async {
|
||||||
await Future.delayed(const Duration(milliseconds: 200));
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
final _lastItem = childrenItems.last;
|
final lastItem = childrenItems.last;
|
||||||
|
|
||||||
if (selectedMailboxNode.expandMode == ExpandMode.COLLAPSE) {
|
if (selectedMailboxNode.expandMode == ExpandMode.COLLAPSE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_lastItem.mailboxNameAsString.contains(selectedMailboxNode.mailboxNameAsString)) {
|
if (lastItem.mailboxNameAsString.contains(selectedMailboxNode.mailboxNameAsString)) {
|
||||||
scrollController.animateTo(
|
scrollController.animateTo(
|
||||||
scrollController.position.maxScrollExtent,
|
scrollController.position.maxScrollExtent,
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'package:core/presentation/extensions/uri_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/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.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/capability/capability_identifier.dart';
|
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
|
||||||
@@ -35,30 +34,29 @@ abstract class ReloadableController extends BaseController {
|
|||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onData(Either<Failure, Success> newState) {
|
void handleFailureViewState(Failure failure) {
|
||||||
super.onData(newState);
|
super.handleFailureViewState(failure);
|
||||||
viewState.value.fold(
|
if (failure is GetCredentialFailure) {
|
||||||
(failure) {
|
goToLogin(arguments: LoginArguments(LoginFormType.credentialForm));
|
||||||
if (failure is GetCredentialFailure) {
|
} else if (failure is GetSessionFailure) {
|
||||||
goToLogin(arguments: LoginArguments(LoginFormType.credentialForm));
|
_handleGetSessionFailure();
|
||||||
} else if (failure is GetSessionFailure) {
|
} else if (failure is GetStoredTokenOidcFailure) {
|
||||||
_handleGetSessionFailure();
|
goToLogin(arguments: LoginArguments(LoginFormType.ssoForm));
|
||||||
} else if (failure is GetStoredTokenOidcFailure) {
|
} else if (failure is GetAuthenticatedAccountFailure || failure is NoAuthenticatedAccountFailure) {
|
||||||
goToLogin(arguments: LoginArguments(LoginFormType.ssoForm));
|
goToLogin(arguments: LoginArguments(LoginFormType.credentialForm));
|
||||||
} else if (failure is GetAuthenticatedAccountFailure || failure is NoAuthenticatedAccountFailure) {
|
}
|
||||||
goToLogin(arguments: LoginArguments(LoginFormType.credentialForm));
|
}
|
||||||
}
|
|
||||||
},
|
@override
|
||||||
(success) {
|
void handleSuccessViewState(Success success) {
|
||||||
if (success is GetCredentialViewState) {
|
super.handleSuccessViewState(success);
|
||||||
_handleGetCredentialSuccess(success);
|
if (success is GetCredentialViewState) {
|
||||||
} else if (success is GetSessionSuccess) {
|
_handleGetCredentialSuccess(success);
|
||||||
_handleGetSessionSuccess(success);
|
} else if (success is GetSessionSuccess) {
|
||||||
} else if (success is GetStoredTokenOidcSuccess) {
|
_handleGetSessionSuccess(success);
|
||||||
_handleGetStoredTokenOIDCSuccess(success);
|
} else if (success is GetStoredTokenOidcSuccess) {
|
||||||
}
|
_handleGetStoredTokenOIDCSuccess(success);
|
||||||
}
|
}
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -91,7 +89,7 @@ abstract class ReloadableController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _getSessionAction() {
|
void _getSessionAction() {
|
||||||
consumeState(_getSessionInteractor.execute().asStream());
|
consumeState(_getSessionInteractor.execute());
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleGetSessionFailure() async {
|
void _handleGetSessionFailure() async {
|
||||||
|
|||||||
@@ -266,51 +266,44 @@ class ComposerController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onData(Either<Failure, Success> newState) {
|
void handleSuccessViewState(Success success) {
|
||||||
super.onData(newState);
|
super.handleSuccessViewState(success);
|
||||||
newState.map((success) async {
|
if (success is GetEmailContentLoading) {
|
||||||
if (success is GetEmailContentLoading) {
|
emailContentsViewState.value = Right(success);
|
||||||
emailContentsViewState.value = Right(success);
|
} else if (success is LocalFilePickerSuccess) {
|
||||||
|
_pickFileSuccess(success);
|
||||||
|
} else if (success is GetEmailContentSuccess) {
|
||||||
|
_getEmailContentSuccess(success);
|
||||||
|
} else if (success is GetAllIdentitiesSuccess) {
|
||||||
|
_handleGetAllIdentitiesSuccess(success);
|
||||||
|
} else if (success is DownloadImageAsBase64Success) {
|
||||||
|
if (BuildUtils.isWeb) {
|
||||||
|
richTextWebController.insertImage(
|
||||||
|
InlineImage(
|
||||||
|
ImageSource.local,
|
||||||
|
fileInfo: success.fileInfo,
|
||||||
|
cid: success.cid,
|
||||||
|
base64Uri: success.base64Uri));
|
||||||
|
} else {
|
||||||
|
richTextMobileTabletController.insertImage(
|
||||||
|
InlineImage(
|
||||||
|
ImageSource.local,
|
||||||
|
fileInfo: success.fileInfo,
|
||||||
|
cid: success.cid,
|
||||||
|
base64Uri: success.base64Uri));
|
||||||
}
|
}
|
||||||
});
|
maxWithEditor = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {
|
void handleFailureViewState(Failure failure) {
|
||||||
viewState.value.fold(
|
super.handleFailureViewState(failure);
|
||||||
(failure) {
|
if (failure is LocalFilePickerFailure || failure is LocalFilePickerCancel) {
|
||||||
if (failure is LocalFilePickerFailure || failure is LocalFilePickerCancel) {
|
_pickFileFailure(failure);
|
||||||
_pickFileFailure(failure);
|
} else if (failure is GetEmailContentFailure) {
|
||||||
} else if (failure is GetEmailContentFailure) {
|
emailContentsViewState.value = Left(failure);
|
||||||
emailContentsViewState.value = Left(failure);
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
(success) {
|
|
||||||
if (success is LocalFilePickerSuccess) {
|
|
||||||
_pickFileSuccess(success);
|
|
||||||
} else if (success is GetEmailContentSuccess) {
|
|
||||||
_getEmailContentSuccess(success);
|
|
||||||
} else if (success is GetAllIdentitiesSuccess) {
|
|
||||||
_handleGetAllIdentitiesSuccess(success);
|
|
||||||
} else if (success is DownloadImageAsBase64Success) {
|
|
||||||
if(kIsWeb) {
|
|
||||||
richTextWebController.insertImage(
|
|
||||||
InlineImage(
|
|
||||||
ImageSource.local,
|
|
||||||
fileInfo: success.fileInfo,
|
|
||||||
cid: success.cid,
|
|
||||||
base64Uri: success.base64Uri));
|
|
||||||
} else {
|
|
||||||
richTextMobileTabletController.insertImage(
|
|
||||||
InlineImage(
|
|
||||||
ImageSource.local,
|
|
||||||
fileInfo: success.fileInfo,
|
|
||||||
cid: success.cid,
|
|
||||||
base64Uri: success.base64Uri));
|
|
||||||
}
|
|
||||||
maxWithEditor = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _listenWorker() {
|
void _listenWorker() {
|
||||||
|
|||||||
@@ -190,7 +190,4 @@ class ContactController extends BaseController {
|
|||||||
popBack();
|
popBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void onDone() {}
|
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,6 @@ 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/utils/app_toast.dart';
|
import 'package:core/presentation/utils/app_toast.dart';
|
||||||
import 'package:core/utils/build_utils.dart';
|
import 'package:core/utils/build_utils.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||||
@@ -112,42 +111,33 @@ class DestinationPickerController extends BaseMailboxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onData(Either<Failure, Success> newState) {
|
void handleSuccessViewState(Success success) {
|
||||||
super.onData(newState);
|
super.handleSuccessViewState(success);
|
||||||
newState.map((success) {
|
if (success is GetAllMailboxSuccess) {
|
||||||
if (success is GetAllMailboxSuccess) {
|
if (mailboxAction.value == MailboxActions.move && mailboxIdSelected != null) {
|
||||||
if (mailboxAction.value == MailboxActions.move && mailboxIdSelected != null) {
|
buildTree(
|
||||||
buildTree(
|
success.mailboxList.listSubscribedMailboxesAndDefaultMailboxes,
|
||||||
success.mailboxList.listSubscribedMailboxesAndDefaultMailboxes,
|
mailboxIdSelected: mailboxIdSelected);
|
||||||
mailboxIdSelected: mailboxIdSelected
|
} else {
|
||||||
);
|
buildTree(success.mailboxList.listSubscribedMailboxesAndDefaultMailboxes);
|
||||||
} else {
|
|
||||||
buildTree(success.mailboxList.listSubscribedMailboxesAndDefaultMailboxes);
|
|
||||||
}
|
|
||||||
} else if (success is RefreshChangesAllMailboxSuccess) {
|
|
||||||
refreshTree(success.mailboxList.listSubscribedMailboxesAndDefaultMailboxes);
|
|
||||||
}
|
}
|
||||||
});
|
} else if (success is RefreshChangesAllMailboxSuccess) {
|
||||||
|
refreshTree(success.mailboxList.listSubscribedMailboxesAndDefaultMailboxes);
|
||||||
|
} else if (success is SearchMailboxSuccess) {
|
||||||
|
_searchMailboxSuccess(success);
|
||||||
|
} else if (success is CreateNewMailboxSuccess) {
|
||||||
|
_createNewMailboxSuccess(success);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {
|
void handleFailureViewState(Failure failure) {
|
||||||
viewState.value.fold(
|
super.handleFailureViewState(failure);
|
||||||
(failure) {
|
if (failure is SearchMailboxFailure) {
|
||||||
if (failure is SearchMailboxFailure) {
|
_searchMailboxFailure(failure);
|
||||||
_searchMailboxFailure(failure);
|
} else if (failure is CreateNewMailboxFailure) {
|
||||||
} else if (failure is CreateNewMailboxFailure) {
|
_createNewMailboxFailure(failure);
|
||||||
_createNewMailboxFailure(failure);
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
(success) {
|
|
||||||
if (success is SearchMailboxSuccess) {
|
|
||||||
_searchMailboxSuccess(success);
|
|
||||||
} else if (success is CreateNewMailboxSuccess) {
|
|
||||||
_createNewMailboxSuccess(success);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -138,6 +138,44 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
|||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleSuccessViewState(Success success) {
|
||||||
|
super.handleSuccessViewState(success);
|
||||||
|
if (success is GetEmailContentSuccess) {
|
||||||
|
_getEmailContentSuccess(success);
|
||||||
|
} else if (success is MarkAsEmailReadSuccess) {
|
||||||
|
_markAsEmailReadSuccess(success);
|
||||||
|
} else if (success is ExportAttachmentSuccess) {
|
||||||
|
_exportAttachmentSuccessAction(success);
|
||||||
|
} else if (success is MoveToMailboxSuccess) {
|
||||||
|
_moveToMailboxSuccess(success);
|
||||||
|
} else if (success is MarkAsStarEmailSuccess) {
|
||||||
|
_markAsEmailStarSuccess(success);
|
||||||
|
} else if (success is DownloadAttachmentForWebSuccess) {
|
||||||
|
_downloadAttachmentForWebSuccessAction(success);
|
||||||
|
} else if (success is GetAllIdentitiesSuccess) {
|
||||||
|
_getAllIdentitiesSuccess(success);
|
||||||
|
} else if (success is SendReceiptToSenderSuccess) {
|
||||||
|
_sendReceiptToSenderSuccess(success);
|
||||||
|
} else if (success is CreateNewRuleFilterSuccess) {
|
||||||
|
_createNewRuleFilterSuccess(success);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleFailureViewState(Failure failure) {
|
||||||
|
super.handleFailureViewState(failure);
|
||||||
|
if (failure is MarkAsEmailReadFailure) {
|
||||||
|
_markAsEmailReadFailure(failure);
|
||||||
|
} else if (failure is DownloadAttachmentsFailure) {
|
||||||
|
_downloadAttachmentsFailure(failure);
|
||||||
|
} else if (failure is ExportAttachmentFailure) {
|
||||||
|
_exportAttachmentFailureAction(failure);
|
||||||
|
} else if (failure is DownloadAttachmentForWebFailure) {
|
||||||
|
_downloadAttachmentForWebFailureAction(failure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _registerObxStreamListener() {
|
void _registerObxStreamListener() {
|
||||||
ever(mailboxDashBoardController.accountId, (accountId) {
|
ever(mailboxDashBoardController.accountId, (accountId) {
|
||||||
if (accountId is AccountId) {
|
if (accountId is AccountId) {
|
||||||
@@ -311,43 +349,6 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void onDone() {
|
|
||||||
viewState.value.fold(
|
|
||||||
(failure) {
|
|
||||||
if (failure is MarkAsEmailReadFailure) {
|
|
||||||
_markAsEmailReadFailure(failure);
|
|
||||||
} else if (failure is DownloadAttachmentsFailure) {
|
|
||||||
_downloadAttachmentsFailure(failure);
|
|
||||||
} else if (failure is ExportAttachmentFailure) {
|
|
||||||
_exportAttachmentFailureAction(failure);
|
|
||||||
} else if (failure is DownloadAttachmentForWebFailure) {
|
|
||||||
_downloadAttachmentForWebFailureAction(failure);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
(success) {
|
|
||||||
if (success is GetEmailContentSuccess) {
|
|
||||||
_getEmailContentSuccess(success);
|
|
||||||
} else if (success is MarkAsEmailReadSuccess) {
|
|
||||||
_markAsEmailReadSuccess(success);
|
|
||||||
} else if (success is ExportAttachmentSuccess) {
|
|
||||||
_exportAttachmentSuccessAction(success);
|
|
||||||
} else if (success is MoveToMailboxSuccess) {
|
|
||||||
_moveToMailboxSuccess(success);
|
|
||||||
} else if (success is MarkAsStarEmailSuccess) {
|
|
||||||
_markAsEmailStarSuccess(success);
|
|
||||||
} else if (success is DownloadAttachmentForWebSuccess) {
|
|
||||||
_downloadAttachmentForWebSuccessAction(success);
|
|
||||||
} else if (success is GetAllIdentitiesSuccess) {
|
|
||||||
_getAllIdentitiesSuccess(success);
|
|
||||||
} else if (success is SendReceiptToSenderSuccess) {
|
|
||||||
_sendReceiptToSenderSuccess(success);
|
|
||||||
} else if (success is CreateNewRuleFilterSuccess) {
|
|
||||||
_createNewRuleFilterSuccess(success);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _getEmailContentSuccess(GetEmailContentSuccess success) {
|
void _getEmailContentSuccess(GetEmailContentSuccess success) {
|
||||||
if(emailSupervisorController.presentationEmailsLoaded.length > ThreadConstants.defaultLimit.value.toInt()) {
|
if(emailSupervisorController.presentationEmailsLoaded.length > ThreadConstants.defaultLimit.value.toInt()) {
|
||||||
emailSupervisorController.popFirstEmailQueue();
|
emailSupervisorController.popFirstEmailQueue();
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ class HomeBindings extends BaseBindings {
|
|||||||
Get.find<CleanupRecentSearchCacheInteractor>(),
|
Get.find<CleanupRecentSearchCacheInteractor>(),
|
||||||
Get.find<CleanupRecentLoginUrlCacheInteractor>(),
|
Get.find<CleanupRecentLoginUrlCacheInteractor>(),
|
||||||
Get.find<CleanupRecentLoginUsernameCacheInteractor>(),
|
Get.find<CleanupRecentLoginUsernameCacheInteractor>(),
|
||||||
Get.find<CheckOIDCIsAvailableInteractor>(),
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:core/core.dart';
|
import 'package:core/core.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter_downloader/flutter_downloader.dart';
|
import 'package:flutter_downloader/flutter_downloader.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -17,16 +16,14 @@ import 'package:tmail_ui_user/features/cleanup/domain/usecases/cleanup_email_cac
|
|||||||
import 'package:tmail_ui_user/features/cleanup/domain/usecases/cleanup_recent_login_url_cache_interactor.dart';
|
import 'package:tmail_ui_user/features/cleanup/domain/usecases/cleanup_recent_login_url_cache_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/cleanup/domain/usecases/cleanup_recent_login_username_interactor.dart';
|
import 'package:tmail_ui_user/features/cleanup/domain/usecases/cleanup_recent_login_username_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/cleanup/domain/usecases/cleanup_recent_search_cache_interactor.dart';
|
import 'package:tmail_ui_user/features/cleanup/domain/usecases/cleanup_recent_search_cache_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/state/check_oidc_is_available_state.dart';
|
import 'package:tmail_ui_user/features/login/domain/state/get_authenticated_account_state.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/state/get_credential_state.dart';
|
import 'package:tmail_ui_user/features/login/domain/state/get_credential_state.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/state/get_stored_token_oidc_state.dart';
|
import 'package:tmail_ui_user/features/login/domain/state/get_stored_token_oidc_state.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/usecases/check_oidc_is_available_interactor.dart';
|
|
||||||
import 'package:tmail_ui_user/features/login/domain/usecases/get_authenticated_account_interactor.dart';
|
import 'package:tmail_ui_user/features/login/domain/usecases/get_authenticated_account_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/login/presentation/login_form_type.dart';
|
import 'package:tmail_ui_user/features/login/presentation/login_form_type.dart';
|
||||||
import 'package:tmail_ui_user/features/login/presentation/model/login_arguments.dart';
|
import 'package:tmail_ui_user/features/login/presentation/model/login_arguments.dart';
|
||||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||||
import 'package:tmail_ui_user/main/utils/app_config.dart';
|
|
||||||
import 'package:tmail_ui_user/main/utils/email_receive_manager.dart';
|
import 'package:tmail_ui_user/main/utils/email_receive_manager.dart';
|
||||||
|
|
||||||
class HomeController extends BaseController {
|
class HomeController extends BaseController {
|
||||||
@@ -37,7 +34,6 @@ class HomeController extends BaseController {
|
|||||||
final CleanupRecentSearchCacheInteractor _cleanupRecentSearchCacheInteractor;
|
final CleanupRecentSearchCacheInteractor _cleanupRecentSearchCacheInteractor;
|
||||||
final CleanupRecentLoginUrlCacheInteractor _cleanupRecentLoginUrlCacheInteractor;
|
final CleanupRecentLoginUrlCacheInteractor _cleanupRecentLoginUrlCacheInteractor;
|
||||||
final CleanupRecentLoginUsernameCacheInteractor _cleanupRecentLoginUsernameCacheInteractor;
|
final CleanupRecentLoginUsernameCacheInteractor _cleanupRecentLoginUsernameCacheInteractor;
|
||||||
final CheckOIDCIsAvailableInteractor _checkOIDCIsAvailableInteractor;
|
|
||||||
|
|
||||||
HomeController(
|
HomeController(
|
||||||
this._getAuthenticatedAccountInteractor,
|
this._getAuthenticatedAccountInteractor,
|
||||||
@@ -47,14 +43,12 @@ class HomeController extends BaseController {
|
|||||||
this._cleanupRecentSearchCacheInteractor,
|
this._cleanupRecentSearchCacheInteractor,
|
||||||
this._cleanupRecentLoginUrlCacheInteractor,
|
this._cleanupRecentLoginUrlCacheInteractor,
|
||||||
this._cleanupRecentLoginUsernameCacheInteractor,
|
this._cleanupRecentLoginUsernameCacheInteractor,
|
||||||
this._checkOIDCIsAvailableInteractor,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Account? currentAccount;
|
Account? currentAccount;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
log('HomeController::onInit(): ');
|
|
||||||
if (!kIsWeb) {
|
if (!kIsWeb) {
|
||||||
_initFlutterDownloader();
|
_initFlutterDownloader();
|
||||||
_registerReceivingSharingIntent();
|
_registerReceivingSharingIntent();
|
||||||
@@ -120,65 +114,23 @@ class HomeController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onData(Either<Failure, Success> newState) {
|
void handleFailureViewState(Failure failure) async {
|
||||||
super.onData(newState);
|
super.handleFailureViewState(failure);
|
||||||
newState.fold(_handleFailureViewState, _handleSuccessViewState);
|
if (failure is NoAuthenticatedAccountFailure ||
|
||||||
}
|
failure is GetAuthenticatedAccountFailure ||
|
||||||
|
failure is GetStoredTokenOidcFailure ||
|
||||||
@override
|
failure is GetCredentialFailure) {
|
||||||
void onDone() {}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onError(error) {
|
|
||||||
_clearAllCacheAndCredential();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleFailureViewState(Failure failure) async {
|
|
||||||
logError('HomeController::_handleFailureViewState(): ${failure.toString()}');
|
|
||||||
if (failure is CheckOIDCIsAvailableFailure) {
|
|
||||||
_goToLogin(arguments: LoginArguments(LoginFormType.credentialForm));
|
_goToLogin(arguments: LoginArguments(LoginFormType.credentialForm));
|
||||||
} else {
|
|
||||||
_clearAllCacheAndCredential();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleSuccessViewState(Success success) {
|
@override
|
||||||
log('HomeController::_handleSuccessViewState(): $success');
|
void handleSuccessViewState(Success success) {
|
||||||
|
super.handleSuccessViewState(success);
|
||||||
if (success is GetStoredTokenOidcSuccess) {
|
if (success is GetStoredTokenOidcSuccess) {
|
||||||
_goToSessionWithTokenOidc(success);
|
_goToSessionWithTokenOidc(success);
|
||||||
} else if (success is GetCredentialViewState) {
|
} else if (success is GetCredentialViewState) {
|
||||||
_goToSessionWithBasicAuth(success);
|
_goToSessionWithBasicAuth(success);
|
||||||
} else if (success is CheckOIDCIsAvailableSuccess) {
|
|
||||||
_goToLogin(arguments: LoginArguments(LoginFormType.ssoForm));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _clearAllCacheAndCredential() async {
|
|
||||||
await Future.wait([
|
|
||||||
deleteCredentialInteractor.execute(),
|
|
||||||
deleteAuthorityOidcInteractor.execute(),
|
|
||||||
cachingManager.clearAll()
|
|
||||||
]).then((value) {
|
|
||||||
if (BuildUtils.isWeb) {
|
|
||||||
_checkOIDCIsAvailable();
|
|
||||||
} else {
|
|
||||||
_goToLogin();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Uri? _parseUri(String? url) => url != null && url.trim().isNotEmpty
|
|
||||||
? Uri.parse(url.trim())
|
|
||||||
: null;
|
|
||||||
|
|
||||||
void _checkOIDCIsAvailable() async {
|
|
||||||
final baseUri = _parseUri(AppConfig.baseUrl);
|
|
||||||
if (baseUri != null) {
|
|
||||||
consumeState(_checkOIDCIsAvailableInteractor.execute(OIDCRequest(
|
|
||||||
baseUrl: baseUri.toString(),
|
|
||||||
resourceUrl: baseUri.origin)));
|
|
||||||
} else {
|
|
||||||
_goToLogin(arguments: LoginArguments(LoginFormType.credentialForm));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
|
||||||
|
import 'package:core/presentation/state/failure.dart';
|
||||||
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:core/utils/build_utils.dart';
|
import 'package:core/utils/build_utils.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -137,19 +139,19 @@ class IdentityCreatorController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {
|
void handleSuccessViewState(Success success) {
|
||||||
viewState.value.fold(
|
super.handleSuccessViewState(success);
|
||||||
(failure) {
|
if (success is GetAllIdentitiesSuccess) {
|
||||||
if (failure is GetAllIdentitiesFailure) {
|
_getALlIdentitiesSuccess(success);
|
||||||
_getALlIdentitiesFailure(failure);
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
(success) {
|
@override
|
||||||
if (success is GetAllIdentitiesSuccess) {
|
void handleFailureViewState(Failure failure) {
|
||||||
_getALlIdentitiesSuccess(success);
|
super.handleFailureViewState(failure);
|
||||||
}
|
if (failure is GetAllIdentitiesFailure) {
|
||||||
}
|
_getALlIdentitiesFailure(failure);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _checkDefaultIdentityIsSupported() {
|
void _checkDefaultIdentityIsSupported() {
|
||||||
|
|||||||
@@ -72,30 +72,24 @@ abstract class BaseLoginView extends GetWidget<LoginController> {
|
|||||||
|
|
||||||
Widget buildLoginButton(BuildContext context) {
|
Widget buildLoginButton(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.only(bottom: 16, left: 24, right: 24),
|
margin: const EdgeInsets.only(bottom: 16, left: 24, right: 24),
|
||||||
width: responsiveUtils.getDeviceWidth(context),height: 48,
|
width: responsiveUtils.getDeviceWidth(context),height: 48,
|
||||||
child: AbsorbPointer(
|
child: ElevatedButton(
|
||||||
absorbing: !controller.networkConnectionController.isNetworkConnectionAvailable(),
|
key: const Key('loginSubmitForm'),
|
||||||
child: ElevatedButton(
|
style: ButtonStyle(
|
||||||
key: const Key('loginSubmitForm'),
|
foregroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => Colors.white),
|
||||||
style: ButtonStyle(
|
backgroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => AppColor.primaryColor),
|
||||||
foregroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => Colors.white),
|
shape: MaterialStateProperty.all(RoundedRectangleBorder(
|
||||||
backgroundColor: MaterialStateProperty.resolveWith<Color>(
|
borderRadius: BorderRadius.circular(10),
|
||||||
(Set<MaterialState> states) => AppColor.primaryColor.withOpacity(
|
side: const BorderSide(width: 0, color: AppColor.primaryColor)
|
||||||
controller.networkConnectionController.isNetworkConnectionAvailable() ? 1 : 0.5)),
|
))
|
||||||
shape: MaterialStateProperty.all(RoundedRectangleBorder(
|
),
|
||||||
borderRadius: BorderRadius.circular(10),
|
onPressed: loginController.handleLoginPressed,
|
||||||
side: const BorderSide(width: 0, color: AppColor.primaryColor)
|
child: Text(
|
||||||
))
|
AppLocalizations.of(context).signIn,
|
||||||
),
|
style: const TextStyle(fontSize: 16, color: Colors.white)
|
||||||
child: Text(AppLocalizations.of(context).signIn,
|
|
||||||
style: const TextStyle(fontSize: 16, color: Colors.white)
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
loginController.handleLoginPressed();
|
|
||||||
}
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ import 'package:tmail_ui_user/features/login/presentation/login_form_type.dart';
|
|||||||
import 'package:tmail_ui_user/features/login/presentation/model/login_arguments.dart';
|
import 'package:tmail_ui_user/features/login/presentation/model/login_arguments.dart';
|
||||||
import 'package:tmail_ui_user/features/login/presentation/state/login_state.dart';
|
import 'package:tmail_ui_user/features/login/presentation/state/login_state.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oidc_interactor.dart';
|
import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oidc_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/network_status_handle/presentation/network_connnection_controller.dart';
|
|
||||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||||
import 'package:tmail_ui_user/main/routes/navigation_router.dart';
|
import 'package:tmail_ui_user/main/routes/navigation_router.dart';
|
||||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||||
@@ -74,7 +73,6 @@ class LoginController extends ReloadableController {
|
|||||||
|
|
||||||
final TextEditingController urlInputController = TextEditingController();
|
final TextEditingController urlInputController = TextEditingController();
|
||||||
final TextEditingController usernameInputController = TextEditingController();
|
final TextEditingController usernameInputController = TextEditingController();
|
||||||
final NetworkConnectionController networkConnectionController = Get.find<NetworkConnectionController>();
|
|
||||||
|
|
||||||
LoginController(
|
LoginController(
|
||||||
LogoutOidcInteractor logoutOidcInteractor,
|
LogoutOidcInteractor logoutOidcInteractor,
|
||||||
@@ -140,54 +138,59 @@ class LoginController extends ReloadableController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onData(Either<Failure, Success> newState) {
|
void handleFailureViewState(Failure failure) {
|
||||||
super.onData(newState);
|
super.handleFailureViewState(failure);
|
||||||
viewState.value.fold(
|
if (failure is GetAuthenticationInfoFailure) {
|
||||||
(failure) {
|
getAuthenticatedAccountAction();
|
||||||
if (failure is GetAuthenticationInfoFailure) {
|
} else if (failure is CheckOIDCIsAvailableFailure ||
|
||||||
getAuthenticatedAccountAction();
|
failure is GetStoredOidcConfigurationFailure) {
|
||||||
} else if (failure is CheckOIDCIsAvailableFailure ||
|
_showFormLoginWithCredentialAction();
|
||||||
failure is GetStoredOidcConfigurationFailure) {
|
} else if (failure is GetOIDCIsAvailableFailure) {
|
||||||
_showFormLoginWithCredentialAction();
|
loginState.value = LoginState(Left(LoginSSONotAvailableAction()));
|
||||||
} else if (failure is GetOIDCIsAvailableFailure) {
|
_showFormLoginWithCredentialAction();
|
||||||
loginState.value = LoginState(Left(LoginSSONotAvailableAction()));
|
} else if (failure is AuthenticationUserFailure) {
|
||||||
_showFormLoginWithCredentialAction();
|
_loginFailureAction(failure);
|
||||||
} else if (failure is AuthenticationUserFailure) {
|
} else if (failure is GetOIDCConfigurationFailure ||
|
||||||
_loginFailureAction(failure);
|
failure is GetTokenOIDCFailure ||
|
||||||
} else if (failure is GetOIDCConfigurationFailure ||
|
failure is AuthenticateOidcOnBrowserFailure) {
|
||||||
failure is GetTokenOIDCFailure ||
|
loginState.value = LoginState(Left(failure));
|
||||||
failure is AuthenticateOidcOnBrowserFailure) {
|
}
|
||||||
loginState.value = LoginState(Left(failure));
|
}
|
||||||
}
|
|
||||||
},
|
@override
|
||||||
(success) {
|
void handleSuccessViewState(Success success) {
|
||||||
if (success is GetAuthenticationInfoSuccess) {
|
super.handleSuccessViewState(success);
|
||||||
_getStoredOidcConfiguration();
|
if (success is GetAuthenticationInfoSuccess) {
|
||||||
} else if (success is GetStoredOidcConfigurationSuccess) {
|
_getStoredOidcConfiguration();
|
||||||
_getTokenOIDCAction(success.oidcConfiguration);
|
} else if (success is GetStoredOidcConfigurationSuccess) {
|
||||||
} else if (success is CheckOIDCIsAvailableSuccess) {
|
_getTokenOIDCAction(success.oidcConfiguration);
|
||||||
_showFormLoginWithSSOAction(success);
|
} else if (success is CheckOIDCIsAvailableSuccess) {
|
||||||
} else if (success is GetOIDCIsAvailableSuccess) {
|
_showFormLoginWithSSOAction(success);
|
||||||
loginState.value = LoginState(Right(success));
|
} else if (success is GetOIDCIsAvailableSuccess) {
|
||||||
_oidcResponse = success.oidcResponse;
|
loginState.value = LoginState(Right(success));
|
||||||
_getOIDCConfiguration();
|
_oidcResponse = success.oidcResponse;
|
||||||
} else if (success is GetOIDCConfigurationSuccess) {
|
_getOIDCConfiguration();
|
||||||
_getOIDCConfigurationSuccess(success);
|
} else if (success is GetOIDCConfigurationSuccess) {
|
||||||
} else if (success is GetTokenOIDCSuccess) {
|
_getOIDCConfigurationSuccess(success);
|
||||||
_getTokenOIDCSuccess(success);
|
} else if (success is GetTokenOIDCSuccess) {
|
||||||
} else if (success is AuthenticationUserSuccess) {
|
_getTokenOIDCSuccess(success);
|
||||||
_loginSuccessAction(success);
|
} else if (success is AuthenticationUserSuccess) {
|
||||||
} else if (success is GetAuthenticationInfoLoading ||
|
_loginSuccessAction(success);
|
||||||
success is CheckOIDCIsAvailableLoading ||
|
} else if (success is GetAuthenticationInfoLoading ||
|
||||||
success is GetStoredOidcConfigurationLoading ||
|
success is CheckOIDCIsAvailableLoading ||
|
||||||
success is GetOIDCConfigurationLoading ||
|
success is GetStoredOidcConfigurationLoading ||
|
||||||
success is GetTokenOIDCLoading ||
|
success is GetOIDCConfigurationLoading ||
|
||||||
success is AuthenticationUserLoading ||
|
success is GetTokenOIDCLoading ||
|
||||||
success is GetOIDCIsAvailableLoading) {
|
success is AuthenticationUserLoading ||
|
||||||
loginState.value = LoginState(Right(LoginLoadingAction()));
|
success is GetOIDCIsAvailableLoading) {
|
||||||
}
|
loginState.value = LoginState(Right(LoginLoadingAction()));
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleFinallyCommonException() {
|
||||||
|
super.handleFinallyCommonException();
|
||||||
|
loginState.value = LoginState(Right(LoginInitAction()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -404,7 +407,4 @@ class LoginController extends ReloadableController {
|
|||||||
urlInputController.clear();
|
urlInputController.clear();
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void onDone() {}
|
|
||||||
}
|
}
|
||||||
@@ -178,27 +178,23 @@ class LoginView extends BaseLoginView {
|
|||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.only(bottom: 16, left: 24, right: 24),
|
margin: const EdgeInsets.only(bottom: 16, left: 24, right: 24),
|
||||||
width: responsiveUtils.getDeviceWidth(context),height: 48,
|
width: responsiveUtils.getDeviceWidth(context),height: 48,
|
||||||
child: AbsorbPointer(
|
child: ElevatedButton(
|
||||||
absorbing: !controller.networkConnectionController.isNetworkConnectionAvailable(),
|
key: const Key('nextToCredentialForm'),
|
||||||
child: ElevatedButton(
|
style: ButtonStyle(
|
||||||
key: const Key('nextToCredentialForm'),
|
foregroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => Colors.white),
|
||||||
style: ButtonStyle(
|
backgroundColor: MaterialStateProperty.resolveWith<Color>(
|
||||||
foregroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => Colors.white),
|
(Set<MaterialState> states) => AppColor.primaryColor),
|
||||||
backgroundColor: MaterialStateProperty.resolveWith<Color>(
|
shape: MaterialStateProperty.all(RoundedRectangleBorder(
|
||||||
(Set<MaterialState> states) => AppColor.primaryColor.withOpacity(
|
borderRadius: BorderRadius.circular(10),
|
||||||
controller.networkConnectionController.isNetworkConnectionAvailable() ? 1 : 0.5)),
|
side: const BorderSide(width: 0, color: AppColor.primaryColor)
|
||||||
shape: MaterialStateProperty.all(RoundedRectangleBorder(
|
))
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
side: const BorderSide(width: 0, color: AppColor.primaryColor)
|
|
||||||
))
|
|
||||||
),
|
|
||||||
child: Text(AppLocalizations.of(context).next,
|
|
||||||
style: const TextStyle(fontSize: 16, color: Colors.white)
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
loginController.handleNextInUrlInputFormPress();
|
|
||||||
}
|
|
||||||
),
|
),
|
||||||
|
child: Text(AppLocalizations.of(context).next,
|
||||||
|
style: const TextStyle(fontSize: 16, color: Colors.white)
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
loginController.handleNextInUrlInputFormPress();
|
||||||
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,27 +276,23 @@ class LoginView extends BaseLoginView {
|
|||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.only(bottom: 16, left: 24, right: 24),
|
margin: const EdgeInsets.only(bottom: 16, left: 24, right: 24),
|
||||||
width: responsiveUtils.getDeviceWidth(context),height: 48,
|
width: responsiveUtils.getDeviceWidth(context),height: 48,
|
||||||
child: AbsorbPointer(
|
child: ElevatedButton(
|
||||||
absorbing: !controller.networkConnectionController.isNetworkConnectionAvailable(),
|
key: const Key('ssoSubmitForm'),
|
||||||
child: ElevatedButton(
|
style: ButtonStyle(
|
||||||
key: const Key('ssoSubmitForm'),
|
foregroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => Colors.white),
|
||||||
style: ButtonStyle(
|
backgroundColor: MaterialStateProperty.resolveWith<Color>(
|
||||||
foregroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => Colors.white),
|
(Set<MaterialState> states) => AppColor.primaryColor),
|
||||||
backgroundColor: MaterialStateProperty.resolveWith<Color>(
|
shape: MaterialStateProperty.all(RoundedRectangleBorder(
|
||||||
(Set<MaterialState> states) => AppColor.primaryColor.withOpacity(
|
borderRadius: BorderRadius.circular(10),
|
||||||
controller.networkConnectionController.isNetworkConnectionAvailable() ? 1 : 0.5)),
|
side: const BorderSide(width: 0, color: AppColor.primaryColor)
|
||||||
shape: MaterialStateProperty.all(RoundedRectangleBorder(
|
))
|
||||||
borderRadius: BorderRadius.circular(10),
|
),
|
||||||
side: const BorderSide(width: 0, color: AppColor.primaryColor)
|
child: Text(AppLocalizations.of(context).singleSignOn,
|
||||||
))
|
style: const TextStyle(fontSize: 16, color: Colors.white)
|
||||||
),
|
),
|
||||||
child: Text(AppLocalizations.of(context).singleSignOn,
|
onPressed: () {
|
||||||
style: const TextStyle(fontSize: 16, color: Colors.white)
|
loginController.handleSSOPressed();
|
||||||
),
|
}
|
||||||
onPressed: () {
|
|
||||||
loginController.handleSSOPressed();
|
|
||||||
}
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:core/core.dart';
|
import 'package:core/core.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
@@ -146,53 +145,53 @@ class MailboxController extends BaseMailboxController with MailboxActionHandlerM
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onData(Either<Failure, Success> newState) {
|
void handleSuccessViewState(Success success) {
|
||||||
super.onData(newState);
|
super.handleSuccessViewState(success);
|
||||||
newState.map((success) async {
|
if (success is GetAllMailboxSuccess) {
|
||||||
if (success is GetAllMailboxSuccess) {
|
_handleGetAllMailboxSuccess(success);
|
||||||
_handleGetAllMailboxSuccess(success);
|
} else if (success is RefreshChangesAllMailboxSuccess) {
|
||||||
} else if (success is RefreshChangesAllMailboxSuccess) {
|
_handleRefreshChangesAllMailboxSuccess(success);
|
||||||
_handleRefreshChangesAllMailboxSuccess(success);
|
} else if (success is CreateNewMailboxSuccess) {
|
||||||
}
|
_createNewMailboxSuccess(success);
|
||||||
});
|
} else if (success is DeleteMultipleMailboxAllSuccess) {
|
||||||
|
_deleteMultipleMailboxSuccess(success.listMailboxIdDeleted, success.currentMailboxState);
|
||||||
|
} else if (success is DeleteMultipleMailboxHasSomeSuccess) {
|
||||||
|
_deleteMultipleMailboxSuccess(success.listMailboxIdDeleted, success.currentMailboxState);
|
||||||
|
} else if (success is RenameMailboxSuccess) {
|
||||||
|
_refreshMailboxChanges(currentMailboxState: success.currentMailboxState);
|
||||||
|
} else if (success is MoveMailboxSuccess) {
|
||||||
|
_moveMailboxSuccess(success);
|
||||||
|
} else if (success is SubscribeMailboxSuccess) {
|
||||||
|
_handleUnsubscribeMailboxSuccess(success);
|
||||||
|
} else if (success is SubscribeMultipleMailboxAllSuccess) {
|
||||||
|
_handleUnsubscribeMultipleMailboxAllSuccess(success);
|
||||||
|
} else if (success is SubscribeMultipleMailboxHasSomeSuccess) {
|
||||||
|
_handleUnsubscribeMultipleMailboxHasSomeSuccess(success);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleFailureViewState(Failure failure) {
|
||||||
|
super.handleFailureViewState(failure);
|
||||||
|
if (failure is CreateNewMailboxFailure) {
|
||||||
|
_createNewMailboxFailure(failure);
|
||||||
|
} else if (failure is DeleteMultipleMailboxFailure) {
|
||||||
|
_deleteMailboxFailure(failure);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {
|
void onDone() {
|
||||||
viewState.value.fold(
|
super.onDone();
|
||||||
(failure) {
|
viewState.value.fold((failure) => null, (success) {
|
||||||
if (failure is CreateNewMailboxFailure) {
|
if (success is GetAllMailboxSuccess) {
|
||||||
_createNewMailboxFailure(failure);
|
_initialMailboxVariableStorage();
|
||||||
} else if (failure is DeleteMultipleMailboxFailure) {
|
mailboxDashBoardController.getSpamReportBanner();
|
||||||
_deleteMailboxFailure(failure);
|
} else if (success is RefreshChangesAllMailboxSuccess) {
|
||||||
}
|
_initialMailboxVariableStorage(isRefreshChange: true);
|
||||||
},
|
mailboxDashBoardController.refreshSpamReportBanner();
|
||||||
(success) async {
|
|
||||||
if (success is GetAllMailboxSuccess) {
|
|
||||||
_initialMailboxVariableStorage();
|
|
||||||
mailboxDashBoardController.getSpamReportBanner();
|
|
||||||
} else if (success is RefreshChangesAllMailboxSuccess) {
|
|
||||||
_initialMailboxVariableStorage(isRefreshChange: true);
|
|
||||||
mailboxDashBoardController.refreshSpamReportBanner();
|
|
||||||
} else if (success is CreateNewMailboxSuccess) {
|
|
||||||
_createNewMailboxSuccess(success);
|
|
||||||
} else if (success is DeleteMultipleMailboxAllSuccess) {
|
|
||||||
_deleteMultipleMailboxSuccess(success.listMailboxIdDeleted, success.currentMailboxState);
|
|
||||||
} else if (success is DeleteMultipleMailboxHasSomeSuccess) {
|
|
||||||
_deleteMultipleMailboxSuccess(success.listMailboxIdDeleted, success.currentMailboxState);
|
|
||||||
} else if (success is RenameMailboxSuccess) {
|
|
||||||
_refreshMailboxChanges(currentMailboxState: success.currentMailboxState);
|
|
||||||
} else if (success is MoveMailboxSuccess) {
|
|
||||||
_moveMailboxSuccess(success);
|
|
||||||
} else if (success is SubscribeMailboxSuccess) {
|
|
||||||
_handleUnsubscribeMailboxSuccess(success);
|
|
||||||
} else if (success is SubscribeMultipleMailboxAllSuccess) {
|
|
||||||
_handleUnsubscribeMultipleMailboxAllSuccess(success);
|
|
||||||
} else if (success is SubscribeMultipleMailboxHasSomeSuccess) {
|
|
||||||
_handleUnsubscribeMultipleMailboxHasSomeSuccess(success);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleScrollEnable() {
|
void handleScrollEnable() {
|
||||||
|
|||||||
@@ -69,9 +69,6 @@ class MailboxCreatorController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void onDone() {}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
_disposeWidget();
|
_disposeWidget();
|
||||||
|
|||||||
@@ -357,7 +357,4 @@ class AdvancedFilterController extends BaseController {
|
|||||||
_unregisterWorkerListener();
|
_unregisterWorkerListener();
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void onDone() {}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+71
-89
@@ -80,7 +80,6 @@ import 'package:tmail_ui_user/features/manage_account/presentation/extensions/da
|
|||||||
import 'package:tmail_ui_user/features/manage_account/presentation/extensions/vacation_response_extension.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/extensions/vacation_response_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/account_menu_item.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/model/account_menu_item.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/manage_account_arguments.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/model/manage_account_arguments.dart';
|
||||||
import 'package:tmail_ui_user/features/network_status_handle/presentation/network_connnection_controller.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/state/get_email_state_to_refresh_state.dart';
|
import 'package:tmail_ui_user/features/push_notification/domain/state/get_email_state_to_refresh_state.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/state/get_mailbox_state_to_refresh_state.dart';
|
import 'package:tmail_ui_user/features/push_notification/domain/state/get_mailbox_state_to_refresh_state.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/delete_email_state_to_refresh_interactor.dart';
|
import 'package:tmail_ui_user/features/push_notification/domain/usecases/delete_email_state_to_refresh_interactor.dart';
|
||||||
@@ -121,7 +120,6 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
final EmailReceiveManager _emailReceiveManager = Get.find<EmailReceiveManager>();
|
final EmailReceiveManager _emailReceiveManager = Get.find<EmailReceiveManager>();
|
||||||
final SearchController searchController = Get.find<SearchController>();
|
final SearchController searchController = Get.find<SearchController>();
|
||||||
final DownloadController downloadController = Get.find<DownloadController>();
|
final DownloadController downloadController = Get.find<DownloadController>();
|
||||||
final NetworkConnectionController networkConnectionController = Get.find<NetworkConnectionController>();
|
|
||||||
final AppGridDashboardController appGridDashboardController = Get.find<AppGridDashboardController>();
|
final AppGridDashboardController appGridDashboardController = Get.find<AppGridDashboardController>();
|
||||||
final SpamReportController spamReportController = Get.find<SpamReportController>();
|
final SpamReportController spamReportController = Get.find<SpamReportController>();
|
||||||
|
|
||||||
@@ -252,97 +250,81 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onData(Either<Failure, Success> newState) {
|
void handleSuccessViewState(Success success) {
|
||||||
super.onData(newState);
|
super.handleSuccessViewState(success);
|
||||||
viewState.value.fold(
|
if (success is SendingEmailState) {
|
||||||
(failure) {
|
if (currentOverlayContext != null && currentContext != null) {
|
||||||
log('MailboxDashBoardController::onData():failure $failure');
|
_appToast.showToastMessage(
|
||||||
},
|
currentOverlayContext!,
|
||||||
(success) {
|
AppLocalizations.of(currentContext!).your_email_being_sent,
|
||||||
log('MailboxDashBoardController::onData():success $success');
|
leadingSVGIcon: _imagePaths.icSendToast);
|
||||||
if (success is SendingEmailState) {
|
|
||||||
if (currentOverlayContext != null && currentContext != null) {
|
|
||||||
_appToast.showToastMessage(
|
|
||||||
currentOverlayContext!,
|
|
||||||
AppLocalizations.of(currentContext!).your_email_being_sent,
|
|
||||||
leadingSVGIcon: _imagePaths.icSendToast
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else if (success is GetEmailStateToRefreshSuccess) {
|
|
||||||
dispatchEmailUIAction(RefreshChangeEmailAction(success.storedState));
|
|
||||||
_deleteEmailStateToRefreshAction();
|
|
||||||
} else if (success is GetMailboxStateToRefreshSuccess) {
|
|
||||||
dispatchMailboxUIAction(RefreshChangeMailboxAction(success.storedState));
|
|
||||||
_deleteMailboxStateToRefreshAction();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
} else if (success is GetEmailStateToRefreshSuccess) {
|
||||||
|
dispatchEmailUIAction(RefreshChangeEmailAction(success.storedState));
|
||||||
|
_deleteEmailStateToRefreshAction();
|
||||||
|
} else if (success is GetMailboxStateToRefreshSuccess) {
|
||||||
|
dispatchMailboxUIAction(RefreshChangeMailboxAction(success.storedState));
|
||||||
|
_deleteMailboxStateToRefreshAction();
|
||||||
|
} else if (success is SendEmailSuccess) {
|
||||||
|
if (currentOverlayContext != null && currentContext != null) {
|
||||||
|
_appToast.showToastSuccessMessage(
|
||||||
|
currentOverlayContext!,
|
||||||
|
AppLocalizations.of(currentContext!).message_has_been_sent_successfully,
|
||||||
|
leadingSVGIcon: _imagePaths.icSendSuccessToast);
|
||||||
|
}
|
||||||
|
} else if (success is SaveEmailAsDraftsSuccess) {
|
||||||
|
_saveEmailAsDraftsSuccess(success);
|
||||||
|
} else if (success is MoveToMailboxSuccess) {
|
||||||
|
_moveToMailboxSuccess(success);
|
||||||
|
} else if (success is DeleteEmailPermanentlySuccess) {
|
||||||
|
_deleteEmailPermanentlySuccess(success);
|
||||||
|
} else if (success is MarkAsMailboxReadAllSuccess ||
|
||||||
|
success is MarkAsMailboxReadHasSomeEmailFailure) {
|
||||||
|
_markAsReadMailboxSuccess(success);
|
||||||
|
} else if (success is GetAllVacationSuccess) {
|
||||||
|
if (success.listVacationResponse.isNotEmpty) {
|
||||||
|
vacationResponse.value = success.listVacationResponse.first;
|
||||||
|
}
|
||||||
|
} else if (success is UpdateVacationSuccess) {
|
||||||
|
_handleUpdateVacationSuccess(success);
|
||||||
|
} else if (success is MarkAsMultipleEmailReadAllSuccess ||
|
||||||
|
success is MarkAsMultipleEmailReadHasSomeEmailFailure) {
|
||||||
|
_markAsReadSelectedMultipleEmailSuccess(success);
|
||||||
|
} else if (success is MarkAsStarMultipleEmailAllSuccess ||
|
||||||
|
success is MarkAsStarMultipleEmailHasSomeEmailFailure) {
|
||||||
|
_markAsStarMultipleEmailSuccess(success);
|
||||||
|
} else if (success is MoveMultipleEmailToMailboxAllSuccess ||
|
||||||
|
success is MoveMultipleEmailToMailboxHasSomeEmailFailure) {
|
||||||
|
_moveSelectedMultipleEmailToMailboxSuccess(success);
|
||||||
|
} else if (success is EmptyTrashFolderSuccess) {
|
||||||
|
_emptyTrashFolderSuccess(success);
|
||||||
|
} else if (success is DeleteMultipleEmailsPermanentlyAllSuccess ||
|
||||||
|
success is DeleteMultipleEmailsPermanentlyHasSomeEmailFailure) {
|
||||||
|
_deleteMultipleEmailsPermanentlySuccess(success);
|
||||||
|
} else if (success is GetAppDashboardConfigurationSuccess) {
|
||||||
|
appGridDashboardController.handleShowAppDashboard(success.linagoraApplications);
|
||||||
|
} else if(success is GetEmailByIdSuccess) {
|
||||||
|
_moveToEmailDetailedView(success);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {
|
void handleFailureViewState(Failure failure) {
|
||||||
viewState.value.fold(
|
super.handleFailureViewState(failure);
|
||||||
(failure) {
|
if (failure is SendEmailFailure) {
|
||||||
if (failure is SendEmailFailure) {
|
_handleSendEmailFailure(failure);
|
||||||
_handleSendEmailFailure(failure);
|
} else if (failure is SaveEmailAsDraftsFailure) {
|
||||||
} else if (failure is SaveEmailAsDraftsFailure) {
|
_handleSaveEmailAsDraftsFailure(failure);
|
||||||
_handleSaveEmailAsDraftsFailure(failure);
|
} else if (failure is UpdateEmailDraftsFailure) {
|
||||||
} else if (failure is UpdateEmailDraftsFailure) {
|
_handleUpdateEmailAsDraftsFailure(failure);
|
||||||
_handleUpdateEmailAsDraftsFailure(failure);
|
} else if (failure is RemoveEmailDraftsFailure) {
|
||||||
} else if (failure is RemoveEmailDraftsFailure) {
|
clearState();
|
||||||
clearState();
|
} else if (failure is MarkAsMailboxReadAllFailure ||
|
||||||
} else if (failure is MarkAsMailboxReadAllFailure ||
|
failure is MarkAsMailboxReadFailure) {
|
||||||
failure is MarkAsMailboxReadFailure) {
|
_markAsReadMailboxFailure(failure);
|
||||||
_markAsReadMailboxFailure(failure);
|
} else if (failure is GetEmailByIdFailure) {
|
||||||
} else if (failure is GetEmailByIdFailure) {
|
_handleGetEmailDetailedFailed(failure);
|
||||||
_handleGetEmailDetailedFailed(failure);
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
(success) {
|
|
||||||
if (success is SendEmailSuccess) {
|
|
||||||
if (currentOverlayContext != null && currentContext != null) {
|
|
||||||
_appToast.showToastSuccessMessage(
|
|
||||||
currentOverlayContext!,
|
|
||||||
AppLocalizations.of(currentContext!).message_has_been_sent_successfully,
|
|
||||||
leadingSVGIcon: _imagePaths.icSendSuccessToast);
|
|
||||||
}
|
|
||||||
} else if (success is SaveEmailAsDraftsSuccess) {
|
|
||||||
log('MailboxDashBoardController::onDone(): SaveEmailAsDraftsSuccess');
|
|
||||||
_saveEmailAsDraftsSuccess(success);
|
|
||||||
} else if (success is MoveToMailboxSuccess) {
|
|
||||||
_moveToMailboxSuccess(success);
|
|
||||||
} else if (success is DeleteEmailPermanentlySuccess) {
|
|
||||||
_deleteEmailPermanentlySuccess(success);
|
|
||||||
} else if (success is MarkAsMailboxReadAllSuccess ||
|
|
||||||
success is MarkAsMailboxReadHasSomeEmailFailure) {
|
|
||||||
_markAsReadMailboxSuccess(success);
|
|
||||||
} else if (success is GetAllVacationSuccess) {
|
|
||||||
if (success.listVacationResponse.isNotEmpty) {
|
|
||||||
vacationResponse.value = success.listVacationResponse.first;
|
|
||||||
}
|
|
||||||
} else if (success is UpdateVacationSuccess) {
|
|
||||||
_handleUpdateVacationSuccess(success);
|
|
||||||
} else if (success is MarkAsMultipleEmailReadAllSuccess
|
|
||||||
|| success is MarkAsMultipleEmailReadHasSomeEmailFailure) {
|
|
||||||
_markAsReadSelectedMultipleEmailSuccess(success);
|
|
||||||
} else if (success is MarkAsStarMultipleEmailAllSuccess
|
|
||||||
|| success is MarkAsStarMultipleEmailHasSomeEmailFailure) {
|
|
||||||
_markAsStarMultipleEmailSuccess(success);
|
|
||||||
} else if (success is MoveMultipleEmailToMailboxAllSuccess
|
|
||||||
|| success is MoveMultipleEmailToMailboxHasSomeEmailFailure) {
|
|
||||||
_moveSelectedMultipleEmailToMailboxSuccess(success);
|
|
||||||
} else if (success is EmptyTrashFolderSuccess) {
|
|
||||||
_emptyTrashFolderSuccess(success);
|
|
||||||
} else if (success is DeleteMultipleEmailsPermanentlyAllSuccess
|
|
||||||
|| success is DeleteMultipleEmailsPermanentlyHasSomeEmailFailure) {
|
|
||||||
_deleteMultipleEmailsPermanentlySuccess(success);
|
|
||||||
} else if (success is GetAppDashboardConfigurationSuccess) {
|
|
||||||
appGridDashboardController.handleShowAppDashboard(success.linagoraApplications);
|
|
||||||
} else if(success is GetEmailByIdSuccess) {
|
|
||||||
_moveToEmailDetailedView(success);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _registerPendingEmailAddress() {
|
void _registerPendingEmailAddress() {
|
||||||
|
|||||||
@@ -303,9 +303,6 @@ class SearchController extends BaseController with DateRangePickerMixin {
|
|||||||
hideAdvancedSearchFormView();
|
hideAdvancedSearchFormView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void onDone() {}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
searchInputController.dispose();
|
searchInputController.dispose();
|
||||||
|
|||||||
+24
-22
@@ -1,3 +1,5 @@
|
|||||||
|
import 'package:core/presentation/state/failure.dart';
|
||||||
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||||
@@ -39,29 +41,29 @@ class SpamReportController extends BaseController {
|
|||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {
|
void handleSuccessViewState(Success success) {
|
||||||
viewState.value.fold(
|
super.handleSuccessViewState(success);
|
||||||
(failure) {
|
if (success is GetUnreadSpamMailboxSuccess){
|
||||||
if (failure is GetUnreadSpamMailboxFailure || failure is GetSpamMailboxCachedFailure) {
|
_presentationSpamMailbox.value = success.unreadSpamMailbox.toPresentationMailbox();
|
||||||
_presentationSpamMailbox.value = null;
|
} else if (success is StoreLastTimeDismissedSpamReportSuccess) {
|
||||||
}
|
_presentationSpamMailbox.value = null;
|
||||||
},
|
} else if (success is GetSpamReportStateSuccess) {
|
||||||
(success) {
|
_spamReportState.value = success.spamReportState;
|
||||||
if (success is GetUnreadSpamMailboxSuccess){
|
} else if (success is StoreSpamReportStateSuccess) {
|
||||||
_presentationSpamMailbox.value = success.unreadSpamMailbox.toPresentationMailbox();
|
_spamReportState.value = success.spamReportState;
|
||||||
} else if (success is StoreLastTimeDismissedSpamReportSuccess) {
|
} else if (success is GetSpamMailboxCachedSuccess) {
|
||||||
_presentationSpamMailbox.value = null;
|
_presentationSpamMailbox.value = success.spamMailbox.toPresentationMailbox();
|
||||||
} else if (success is GetSpamReportStateSuccess) {
|
}
|
||||||
_spamReportState.value = success.spamReportState;
|
|
||||||
} else if (success is StoreSpamReportStateSuccess) {
|
|
||||||
_spamReportState.value = success.spamReportState;
|
|
||||||
} else if (success is GetSpamMailboxCachedSuccess) {
|
|
||||||
_presentationSpamMailbox.value = success.spamMailbox.toPresentationMailbox();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleFailureViewState(Failure failure) {
|
||||||
|
super.handleFailureViewState(failure);
|
||||||
|
if (failure is GetUnreadSpamMailboxFailure || failure is GetSpamMailboxCachedFailure) {
|
||||||
|
_presentationSpamMailbox.value = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void dismissSpamReportAction() {
|
void dismissSpamReportAction() {
|
||||||
if (Get.isRegistered<MailboxDashBoardController>()) {
|
if (Get.isRegistered<MailboxDashBoardController>()) {
|
||||||
final mailboxDashBoardController = Get.find<MailboxDashBoardController>();
|
final mailboxDashBoardController = Get.find<MailboxDashBoardController>();
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import 'package:core/presentation/utils/html_transformer/dom/blockcode_transform
|
|||||||
import 'package:core/presentation/utils/html_transformer/dom/blockquoted_transformers.dart';
|
import 'package:core/presentation/utils/html_transformer/dom/blockquoted_transformers.dart';
|
||||||
import 'package:core/presentation/utils/html_transformer/dom/image_transformers.dart';
|
import 'package:core/presentation/utils/html_transformer/dom/image_transformers.dart';
|
||||||
import 'package:core/presentation/utils/html_transformer/dom/script_transformers.dart';
|
import 'package:core/presentation/utils/html_transformer/dom/script_transformers.dart';
|
||||||
import 'package:core/presentation/utils/html_transformer/dom/sigature_transformers.dart';
|
|
||||||
import 'package:core/presentation/utils/html_transformer/html_transform.dart';
|
import 'package:core/presentation/utils/html_transformer/html_transform.dart';
|
||||||
import 'package:core/presentation/utils/html_transformer/transform_configuration.dart';
|
import 'package:core/presentation/utils/html_transformer/transform_configuration.dart';
|
||||||
|
import 'package:core/utils/build_utils.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/properties/properties.dart';
|
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||||
@@ -59,12 +59,11 @@ class IdentityDataSourceImpl extends IdentityDataSource {
|
|||||||
final signatureUnescape = await HtmlTransform(signature).transformToHtml(
|
final signatureUnescape = await HtmlTransform(signature).transformToHtml(
|
||||||
transformConfiguration: TransformConfiguration.create(customDomTransformers: [
|
transformConfiguration: TransformConfiguration.create(customDomTransformers: [
|
||||||
const RemoveScriptTransformer(),
|
const RemoveScriptTransformer(),
|
||||||
const SignatureTransformer(),
|
|
||||||
const BlockQuotedTransformer(),
|
const BlockQuotedTransformer(),
|
||||||
const BlockCodeTransformer(),
|
const BlockCodeTransformer(),
|
||||||
const AddTargetBlankInTagATransformer(),
|
const AddTargetBlankInTagATransformer(),
|
||||||
const ImageTransformer(),
|
const ImageTransformer(),
|
||||||
const AddTooltipLinkTransformer()
|
if (BuildUtils.isWeb) const AddTooltipLinkTransformer()
|
||||||
]));
|
]));
|
||||||
return signatureUnescape;
|
return signatureUnescape;
|
||||||
}).catchError(_exceptionThrower.throwException);
|
}).catchError(_exceptionThrower.throwException);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:core/presentation/extensions/color_extension.dart';
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
import 'package:core/presentation/resources/image_paths.dart';
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:core/presentation/utils/app_toast.dart';
|
import 'package:core/presentation/utils/app_toast.dart';
|
||||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||||
import 'package:core/presentation/views/bottom_popup/confirmation_dialog_action_sheet_builder.dart';
|
import 'package:core/presentation/views/bottom_popup/confirmation_dialog_action_sheet_builder.dart';
|
||||||
@@ -46,25 +47,6 @@ class EmailRulesController extends BaseController {
|
|||||||
|
|
||||||
final listEmailRule = <TMailRule>[].obs;
|
final listEmailRule = <TMailRule>[].obs;
|
||||||
|
|
||||||
EmailRulesController();
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onDone() {
|
|
||||||
viewState.value.fold((failure) {}, (success) {
|
|
||||||
if (success is GetAllRulesSuccess) {
|
|
||||||
if (success.rules?.isNotEmpty == true) {
|
|
||||||
listEmailRule.addAll(success.rules!);
|
|
||||||
}
|
|
||||||
} else if (success is DeleteEmailRuleSuccess) {
|
|
||||||
_handleDeleteEmailRuleSuccess(success);
|
|
||||||
} else if (success is CreateNewRuleFilterSuccess) {
|
|
||||||
_createNewRuleFilterSuccess(success);
|
|
||||||
} else if (success is EditEmailRuleFilterSuccess) {
|
|
||||||
_editEmailRuleFilterSuccess(success);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
@@ -84,6 +66,22 @@ class EmailRulesController extends BaseController {
|
|||||||
super.onReady();
|
super.onReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleSuccessViewState(Success success) {
|
||||||
|
super.handleSuccessViewState(success);
|
||||||
|
if (success is GetAllRulesSuccess) {
|
||||||
|
if (success.rules?.isNotEmpty == true) {
|
||||||
|
listEmailRule.addAll(success.rules!);
|
||||||
|
}
|
||||||
|
} else if (success is DeleteEmailRuleSuccess) {
|
||||||
|
_handleDeleteEmailRuleSuccess(success);
|
||||||
|
} else if (success is CreateNewRuleFilterSuccess) {
|
||||||
|
_createNewRuleFilterSuccess(success);
|
||||||
|
} else if (success is EditEmailRuleFilterSuccess) {
|
||||||
|
_editEmailRuleFilterSuccess(success);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void goToCreateNewRule(BuildContext context) async {
|
void goToCreateNewRule(BuildContext context) async {
|
||||||
final accountId = _accountDashBoardController.accountId.value;
|
final accountId = _accountDashBoardController.accountId.value;
|
||||||
final session = _accountDashBoardController.sessionCurrent;
|
final session = _accountDashBoardController.sessionCurrent;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'package:core/presentation/extensions/color_extension.dart';
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
import 'package:core/presentation/resources/image_paths.dart';
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
|
import 'package:core/presentation/state/failure.dart';
|
||||||
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:core/presentation/utils/app_toast.dart';
|
import 'package:core/presentation/utils/app_toast.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -75,34 +77,35 @@ class ForwardController extends BaseController {
|
|||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void onDone() {
|
|
||||||
viewState.value.fold(
|
|
||||||
(failure) {
|
|
||||||
if (failure is DeleteRecipientInForwardingFailure) {
|
|
||||||
cancelSelectionMode();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
(success) {
|
|
||||||
if (success is GetForwardSuccess) {
|
|
||||||
currentForward.value = success.forward;
|
|
||||||
listRecipientForward.value = currentForward.value!.listRecipientForward;
|
|
||||||
} else if (success is DeleteRecipientInForwardingSuccess) {
|
|
||||||
_handleDeleteRecipientSuccess(success);
|
|
||||||
} else if (success is AddRecipientsInForwardingSuccess) {
|
|
||||||
_handleAddRecipientsSuccess(success);
|
|
||||||
} else if (success is EditLocalCopyInForwardingSuccess) {
|
|
||||||
_handleEditLocalCopySuccess(success);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
_getForward();
|
_getForward();
|
||||||
super.onReady();
|
super.onReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleSuccessViewState(Success success) {
|
||||||
|
super.handleSuccessViewState(success);
|
||||||
|
if (success is GetForwardSuccess) {
|
||||||
|
currentForward.value = success.forward;
|
||||||
|
listRecipientForward.value = currentForward.value!.listRecipientForward;
|
||||||
|
} else if (success is DeleteRecipientInForwardingSuccess) {
|
||||||
|
_handleDeleteRecipientSuccess(success);
|
||||||
|
} else if (success is AddRecipientsInForwardingSuccess) {
|
||||||
|
_handleAddRecipientsSuccess(success);
|
||||||
|
} else if (success is EditLocalCopyInForwardingSuccess) {
|
||||||
|
_handleEditLocalCopySuccess(success);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleFailureViewState(Failure failure) {
|
||||||
|
super.handleFailureViewState(failure);
|
||||||
|
if (failure is DeleteRecipientInForwardingFailure) {
|
||||||
|
cancelSelectionMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _getForward() {
|
void _getForward() {
|
||||||
if (_getForwardInteractor != null) {
|
if (_getForwardInteractor != null) {
|
||||||
consumeState(_getForwardInteractor!.execute(accountDashBoardController.accountId.value!));
|
consumeState(_getForwardInteractor!.execute(accountDashBoardController.accountId.value!));
|
||||||
|
|||||||
+6
-8
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||||
@@ -25,14 +26,11 @@ class LanguageAndRegionController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {
|
void handleSuccessViewState(Success success) {
|
||||||
viewState.value.fold(
|
super.handleSuccessViewState(success);
|
||||||
(failure) => null,
|
if (success is SaveLanguageSuccess) {
|
||||||
(success) {
|
LocalizationService.changeLocale(success.localeStored.languageCode);
|
||||||
if (success is SaveLanguageSuccess) {
|
}
|
||||||
LocalizationService.changeLocale(success.localeStored.languageCode);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setUpSupportedLanguages() {
|
void _setUpSupportedLanguages() {
|
||||||
|
|||||||
+15
-25
@@ -1,6 +1,5 @@
|
|||||||
import 'package:core/presentation/extensions/color_extension.dart';
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
import 'package:core/presentation/resources/image_paths.dart';
|
import 'package:core/presentation/resources/image_paths.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/utils/app_toast.dart';
|
import 'package:core/presentation/utils/app_toast.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
@@ -66,30 +65,21 @@ class MailboxVisibilityController extends BaseMailboxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onData(Either<Failure, Success> newState) {
|
void handleSuccessViewState(Success success) {
|
||||||
super.onData(newState);
|
super.handleSuccessViewState(success);
|
||||||
newState.fold((failure) => null, (success) {
|
if (success is GetAllMailboxSuccess) {
|
||||||
if (success is GetAllMailboxSuccess) {
|
currentMailboxState = success.currentMailboxState;
|
||||||
currentMailboxState = success.currentMailboxState;
|
_handleBuildTree(success.mailboxList);
|
||||||
_handleBuildTree(success.mailboxList);
|
} else if (success is RefreshChangesAllMailboxSuccess) {
|
||||||
} else if (success is RefreshChangesAllMailboxSuccess) {
|
currentMailboxState = success.currentMailboxState;
|
||||||
currentMailboxState = success.currentMailboxState;
|
refreshTree(success.mailboxList);
|
||||||
refreshTree(success.mailboxList);
|
} else if (success is SubscribeMailboxSuccess) {
|
||||||
}
|
_subscribeMailboxSuccess(success);
|
||||||
});
|
} else if (success is SubscribeMultipleMailboxAllSuccess) {
|
||||||
}
|
_handleUnsubscribeMultipleMailboxAllSuccess(success);
|
||||||
|
} else if (success is SubscribeMultipleMailboxHasSomeSuccess) {
|
||||||
@override
|
_handleUnsubscribeMultipleMailboxHasSomeSuccess(success);
|
||||||
void onDone() {
|
}
|
||||||
viewState.value.fold((failure) {}, (success) {
|
|
||||||
if (success is SubscribeMailboxSuccess) {
|
|
||||||
_subscribeMailboxSuccess(success);
|
|
||||||
} else if (success is SubscribeMultipleMailboxAllSuccess) {
|
|
||||||
_handleUnsubscribeMultipleMailboxAllSuccess(success);
|
|
||||||
} else if (success is SubscribeMultipleMailboxHasSomeSuccess) {
|
|
||||||
_handleUnsubscribeMultipleMailboxHasSomeSuccess(success);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -77,21 +77,17 @@ class ManageAccountDashBoardController extends ReloadableController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {
|
void handleSuccessViewState(Success success) {
|
||||||
viewState.value.fold(
|
super.handleSuccessViewState(success);
|
||||||
(failure) {},
|
if (success is GetUserProfileSuccess) {
|
||||||
(success) {
|
userProfile.value = success.userProfile;
|
||||||
if (success is GetUserProfileSuccess) {
|
} else if (success is GetAllVacationSuccess) {
|
||||||
userProfile.value = success.userProfile;
|
if (success.listVacationResponse.isNotEmpty) {
|
||||||
} else if (success is GetAllVacationSuccess) {
|
vacationResponse.value = success.listVacationResponse.first;
|
||||||
if (success.listVacationResponse.isNotEmpty) {
|
|
||||||
vacationResponse.value = success.listVacationResponse.first;
|
|
||||||
}
|
|
||||||
} else if (success is UpdateVacationSuccess) {
|
|
||||||
_handleUpdateVacationSuccess(success);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
} else if (success is UpdateVacationSuccess) {
|
||||||
|
_handleUpdateVacationSuccess(success);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
+25
-23
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
import 'package:core/presentation/extensions/color_extension.dart';
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
import 'package:core/presentation/resources/image_paths.dart';
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
|
import 'package:core/presentation/state/failure.dart';
|
||||||
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:core/presentation/utils/app_toast.dart';
|
import 'package:core/presentation/utils/app_toast.dart';
|
||||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||||
import 'package:core/presentation/views/dialog/confirmation_dialog_builder.dart';
|
import 'package:core/presentation/views/dialog/confirmation_dialog_builder.dart';
|
||||||
@@ -72,29 +74,29 @@ class IdentitiesController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {
|
void handleSuccessViewState(Success success) {
|
||||||
viewState.value.fold(
|
super.handleSuccessViewState(success);
|
||||||
(failure) {
|
if (success is GetAllIdentitiesSuccess) {
|
||||||
if (failure is DeleteIdentityFailure) {
|
_handleGetAllIdentitiesSuccess(success);
|
||||||
_deleteIdentityFailure(failure);
|
} else if (success is CreateNewIdentitySuccess) {
|
||||||
}
|
_createNewIdentitySuccess(success);
|
||||||
},
|
} else if (success is CreateNewDefaultIdentitySuccess) {
|
||||||
(success) {
|
_createNewDefaultIdentitySuccess(success);
|
||||||
if (success is GetAllIdentitiesSuccess) {
|
} else if (success is DeleteIdentitySuccess) {
|
||||||
_handleGetAllIdentitiesSuccess(success);
|
_deleteIdentitySuccess(success);
|
||||||
} else if (success is CreateNewIdentitySuccess) {
|
} else if (success is EditIdentitySuccess) {
|
||||||
_createNewIdentitySuccess(success);
|
_editIdentitySuccess(success);
|
||||||
} else if (success is CreateNewDefaultIdentitySuccess) {
|
} else if (success is TransformHtmlSignatureSuccess) {
|
||||||
_createNewDefaultIdentitySuccess(success);
|
signatureSelected.value = success.signature;
|
||||||
} else if (success is DeleteIdentitySuccess) {
|
}
|
||||||
_deleteIdentitySuccess(success);
|
}
|
||||||
} else if (success is EditIdentitySuccess) {
|
|
||||||
_editIdentitySuccess(success);
|
@override
|
||||||
} else if (success is TransformHtmlSignatureSuccess) {
|
void handleFailureViewState(Failure failure) {
|
||||||
signatureSelected.value = success.signature;
|
super.handleFailureViewState(failure);
|
||||||
}
|
if (failure is DeleteIdentityFailure) {
|
||||||
}
|
_deleteIdentityFailure(failure);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _registerObxStreamListener() {
|
void _registerObxStreamListener() {
|
||||||
|
|||||||
@@ -75,17 +75,13 @@ class VacationController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {
|
void handleSuccessViewState(Success success) {
|
||||||
viewState.value.fold(
|
super.handleSuccessViewState(success);
|
||||||
(failure) => null,
|
if (success is GetAllVacationSuccess) {
|
||||||
(success) {
|
_handleGetAllVacationSuccess(success);
|
||||||
if (success is GetAllVacationSuccess) {
|
} else if (success is UpdateVacationSuccess) {
|
||||||
_handleGetAllVacationSuccess(success);
|
_handleUpdateVacationSuccess(success);
|
||||||
} else if (success is UpdateVacationSuccess) {
|
}
|
||||||
_handleUpdateVacationSuccess(success);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _initWorker() {
|
void _initWorker() {
|
||||||
|
|||||||
@@ -40,9 +40,6 @@ class NetworkConnectionController extends BaseController {
|
|||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void onDone() {}
|
|
||||||
|
|
||||||
void _getCurrentNetworkConnectionState() async {
|
void _getCurrentNetworkConnectionState() async {
|
||||||
final currentConnectionResult = await _connectivity.checkConnectivity();
|
final currentConnectionResult = await _connectivity.checkConnectivity();
|
||||||
log('NetworkConnectionController::onReady():_getCurrentNetworkConnectionState: $currentConnectionResult');
|
log('NetworkConnectionController::onReady():_getCurrentNetworkConnectionState: $currentConnectionResult');
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ class FcmMessageController extends FcmBaseController {
|
|||||||
|
|
||||||
void _getSessionAction() {
|
void _getSessionAction() {
|
||||||
if (_getSessionInteractor != null) {
|
if (_getSessionInteractor != null) {
|
||||||
consumeState(_getSessionInteractor!.execute().asStream());
|
consumeState(_getSessionInteractor!.execute());
|
||||||
} else {
|
} else {
|
||||||
_clearRemoteMessageBackground();
|
_clearRemoteMessageBackground();
|
||||||
logError('FcmMessageController::_getSessionAction():_getSessionInteractor is null');
|
logError('FcmMessageController::_getSessionAction():_getSessionInteractor is null');
|
||||||
|
|||||||
@@ -45,22 +45,6 @@ class QuotasController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void onDone() {
|
|
||||||
viewState.value.fold(
|
|
||||||
(failure) {
|
|
||||||
if (failure is GetQuotasFailure) {
|
|
||||||
logError('QuotasController::onDone():[GetQuotasFailure]: ${failure.exception}');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
(success) {
|
|
||||||
if (success is GetQuotasSuccess) {
|
|
||||||
_handleGetQuotasSuccess(success);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleGetQuotasSuccess(GetQuotasSuccess success) {
|
void _handleGetQuotasSuccess(GetQuotasSuccess success) {
|
||||||
try {
|
try {
|
||||||
final quotas = success.quotas.firstWhere((e) => e.resourceType == ResourceType.octets);
|
final quotas = success.quotas.firstWhere((e) => e.resourceType == ResourceType.octets);
|
||||||
@@ -85,10 +69,6 @@ class QuotasController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void covertBytesToGB() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void _initWorker() {
|
void _initWorker() {
|
||||||
accountIdWorker = ever(mailboxDashBoardController.accountId, (accountId) {
|
accountIdWorker = ever(mailboxDashBoardController.accountId, (accountId) {
|
||||||
if (accountId is AccountId && mailboxDashBoardController.sessionCurrent!= null) {
|
if (accountId is AccountId && mailboxDashBoardController.sessionCurrent!= null) {
|
||||||
@@ -108,4 +88,12 @@ class QuotasController extends BaseController {
|
|||||||
accountIdWorker.call();
|
accountIdWorker.call();
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleSuccessViewState(Success success) {
|
||||||
|
super.handleSuccessViewState(success);
|
||||||
|
if (success is GetQuotasSuccess) {
|
||||||
|
_handleGetQuotasSuccess(success);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-23
@@ -1,10 +1,8 @@
|
|||||||
|
|
||||||
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/utils/app_toast.dart';
|
import 'package:core/presentation/utils/app_toast.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:core/utils/build_utils.dart';
|
import 'package:core/utils/build_utils.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||||
@@ -116,28 +114,17 @@ class RulesFilterCreatorController extends BaseMailboxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {
|
void handleSuccessViewState(Success success) async {
|
||||||
viewState.value.fold((failure) {}, (success) {
|
super.handleSuccessViewState(success);
|
||||||
if (success is GetAllRulesSuccess) {
|
if (success is GetAllMailboxSuccess) {
|
||||||
log('RulesFilterCreatorController::onDone():GetAllRulesSuccess: ${success.rules}');
|
await buildTree(success.mailboxList);
|
||||||
if (success.rules?.isNotEmpty == true) {
|
_setUpMailboxSelected();
|
||||||
_listEmailRule = success.rules!;
|
} else if (success is GetAllRulesSuccess) {
|
||||||
}
|
log('RulesFilterCreatorController::handleSuccessViewState():GetAllRulesSuccess: ${success.rules}');
|
||||||
|
if (success.rules?.isNotEmpty == true) {
|
||||||
|
_listEmailRule = success.rules!;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onData(Either<Failure, Success> newState) {
|
|
||||||
super.onData(newState);
|
|
||||||
newState.fold(
|
|
||||||
(failure) => null,
|
|
||||||
(success) async {
|
|
||||||
if (success is GetAllMailboxSuccess) {
|
|
||||||
await buildTree(success.mailboxList);
|
|
||||||
_setUpMailboxSelected();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _getAllRules() {
|
void _getAllRules() {
|
||||||
|
|||||||
@@ -134,32 +134,28 @@ class SearchEmailController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onData(Either<Failure, Success> newState) {
|
void handleSuccessViewState(Success success) {
|
||||||
super.onData(newState);
|
super.handleSuccessViewState(success);
|
||||||
newState.fold(
|
if (success is SearchEmailSuccess) {
|
||||||
(failure) {
|
_searchEmailsSuccess(success);
|
||||||
if (failure is SearchEmailFailure) {
|
} else if (success is SearchingMoreState) {
|
||||||
_searchEmailsFailure(failure);
|
searchMoreState = SearchMoreState.waiting;
|
||||||
} else if (failure is SearchMoreEmailFailure) {
|
} else if (success is SearchMoreEmailSuccess) {
|
||||||
_searchMoreEmailsFailure(failure);
|
_searchMoreEmailsSuccess(success);
|
||||||
}
|
} else if (success is RefreshChangesSearchEmailSuccess) {
|
||||||
},
|
_refreshChangesSearchEmailsSuccess(success);
|
||||||
(success) {
|
}
|
||||||
if (success is SearchEmailSuccess) {
|
|
||||||
_searchEmailsSuccess(success);
|
|
||||||
} else if (success is SearchingMoreState) {
|
|
||||||
searchMoreState = SearchMoreState.waiting;
|
|
||||||
} else if (success is SearchMoreEmailSuccess) {
|
|
||||||
_searchMoreEmailsSuccess(success);
|
|
||||||
} else if (success is RefreshChangesSearchEmailSuccess) {
|
|
||||||
_refreshChangesSearchEmailsSuccess(success);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {}
|
void handleFailureViewState(Failure failure) {
|
||||||
|
super.handleFailureViewState(failure);
|
||||||
|
if (failure is SearchEmailFailure) {
|
||||||
|
_searchEmailsFailure(failure);
|
||||||
|
} else if (failure is SearchMoreEmailFailure) {
|
||||||
|
_searchMoreEmailsFailure(failure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _initializeDebounceTimeTextSearchChange() {
|
void _initializeDebounceTimeTextSearchChange() {
|
||||||
_deBouncerTime = Debouncer<String>(
|
_deBouncerTime = Debouncer<String>(
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import 'package:core/presentation/utils/app_toast.dart';
|
|||||||
import 'package:core/presentation/utils/responsive_utils.dart';
|
import 'package:core/presentation/utils/responsive_utils.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:core/utils/build_utils.dart';
|
import 'package:core/utils/build_utils.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -107,33 +106,24 @@ class SearchMailboxController extends BaseMailboxController with MailboxActionHa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {
|
void handleFailureViewState(Failure failure) {
|
||||||
viewState.value.fold(_handleFailureViewState, _handleSuccessViewState);
|
super.handleFailureViewState(failure);
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void onData(Either<Failure, Success> newState) {
|
|
||||||
super.onData(newState);
|
|
||||||
newState.fold((failure) => null, (success) async {
|
|
||||||
if (success is GetAllMailboxSuccess) {
|
|
||||||
currentMailboxState = success.currentMailboxState;
|
|
||||||
buildTree(success.mailboxList);
|
|
||||||
} else if (success is RefreshChangesAllMailboxSuccess) {
|
|
||||||
currentMailboxState = success.currentMailboxState;
|
|
||||||
await refreshTree(success.mailboxList);
|
|
||||||
searchMailboxAction();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleFailureViewState(Failure failure) {
|
|
||||||
if (failure is SearchMailboxFailure) {
|
if (failure is SearchMailboxFailure) {
|
||||||
_handleSearchMailboxFailure(failure);
|
_handleSearchMailboxFailure(failure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleSuccessViewState(Success success) {
|
@override
|
||||||
if (success is SearchMailboxSuccess) {
|
void handleSuccessViewState(Success success) async {
|
||||||
|
super.handleSuccessViewState(success);
|
||||||
|
if (success is GetAllMailboxSuccess) {
|
||||||
|
currentMailboxState = success.currentMailboxState;
|
||||||
|
buildTree(success.mailboxList);
|
||||||
|
} else if (success is RefreshChangesAllMailboxSuccess) {
|
||||||
|
currentMailboxState = success.currentMailboxState;
|
||||||
|
await refreshTree(success.mailboxList);
|
||||||
|
searchMailboxAction();
|
||||||
|
} else if (success is SearchMailboxSuccess) {
|
||||||
_handleSearchMailboxSuccess(success);
|
_handleSearchMailboxSuccess(success);
|
||||||
} else if (success is MarkAsMailboxReadAllSuccess) {
|
} else if (success is MarkAsMailboxReadAllSuccess) {
|
||||||
_refreshMailboxChanges(mailboxState: success.currentMailboxState);
|
_refreshMailboxChanges(mailboxState: success.currentMailboxState);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:core/core.dart';
|
import 'package:core/presentation/state/failure.dart';
|
||||||
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:tmail_ui_user/features/session/domain/repository/session_repository.dart';
|
import 'package:tmail_ui_user/features/session/domain/repository/session_repository.dart';
|
||||||
import 'package:tmail_ui_user/features/session/domain/state/get_session_state.dart';
|
import 'package:tmail_ui_user/features/session/domain/state/get_session_state.dart';
|
||||||
@@ -8,12 +9,12 @@ class GetSessionInteractor {
|
|||||||
|
|
||||||
GetSessionInteractor(this.sessionRepository);
|
GetSessionInteractor(this.sessionRepository);
|
||||||
|
|
||||||
Future<Either<Failure, Success>> execute() async {
|
Stream<Either<Failure, Success>> execute() async* {
|
||||||
try {
|
try {
|
||||||
final session = await sessionRepository.getSession();
|
final session = await sessionRepository.getSession();
|
||||||
return Right<Failure, Success>(GetSessionSuccess(session));
|
yield Right<Failure, Success>(GetSessionSuccess(session));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Left<Failure, Success>(GetSessionFailure(e));
|
yield Left<Failure, Success>(GetSessionFailure(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:core/data/network/config/dynamic_url_interceptors.dart';
|
import 'package:core/data/network/config/dynamic_url_interceptors.dart';
|
||||||
import 'package:core/presentation/extensions/uri_extension.dart';
|
import 'package:core/presentation/extensions/uri_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/utils/app_toast.dart';
|
import 'package:core/presentation/utils/app_toast.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -49,6 +50,23 @@ class SessionController extends ReloadableController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleFailureViewState(Failure failure) {
|
||||||
|
super.handleFailureViewState(failure);
|
||||||
|
if (failure is GetSessionFailure) {
|
||||||
|
_handleSessionFailure(failure);
|
||||||
|
_goToLogin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleSuccessViewState(Success success) {
|
||||||
|
super.handleSuccessViewState(success);
|
||||||
|
if (success is GetSessionSuccess) {
|
||||||
|
_goToMailboxDashBoard(success);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleReloaded(Session session) {
|
void handleReloaded(Session session) {
|
||||||
pushAndPop(
|
pushAndPop(
|
||||||
@@ -57,15 +75,7 @@ class SessionController extends ReloadableController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _getSession() async {
|
void _getSession() async {
|
||||||
await _getSessionInteractor.execute()
|
consumeState(_getSessionInteractor.execute());
|
||||||
.then((response) => response.fold(
|
|
||||||
(failure) {
|
|
||||||
_handleSessionFailure(failure);
|
|
||||||
_goToLogin();
|
|
||||||
},
|
|
||||||
(success) => success is GetSessionSuccess
|
|
||||||
? _goToMailboxDashBoard(success)
|
|
||||||
: _goToLogin()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleSessionFailure(Failure failure) {
|
void _handleSessionFailure(Failure failure) {
|
||||||
@@ -93,7 +103,7 @@ class SessionController extends ReloadableController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool _checkUrlError(dynamic sessionException) {
|
bool _checkUrlError(dynamic sessionException) {
|
||||||
return sessionException is ConnectError || sessionException is BadGateway;
|
return sessionException is ConnectError || sessionException is BadGateway || sessionException is SocketError;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _goToLogin() async {
|
void _goToLogin() async {
|
||||||
@@ -121,7 +131,4 @@ class SessionController extends ReloadableController {
|
|||||||
_goToLogin();
|
_goToLogin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void onDone() {}
|
|
||||||
}
|
}
|
||||||
@@ -146,50 +146,47 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onData(Either<Failure, Success> newState) {
|
void handleSuccessViewState(Success success) {
|
||||||
super.onData(newState);
|
super.handleSuccessViewState(success);
|
||||||
newState.fold(
|
if (success is GetAllEmailSuccess) {
|
||||||
(failure) {
|
_getAllEmailSuccess(success);
|
||||||
if (failure is SearchEmailFailure) {
|
} else if (success is RefreshChangesAllEmailSuccess) {
|
||||||
canSearchMore = false;
|
_refreshChangesAllEmailSuccess(success);
|
||||||
mailboxDashBoardController.emailsInCurrentMailbox.clear();
|
} else if (success is LoadMoreEmailsSuccess) {
|
||||||
} else if (failure is SearchMoreEmailFailure || failure is LoadMoreEmailsFailure) {
|
_loadMoreEmailsSuccess(success);
|
||||||
_isLoadingMore = false;
|
} else if (success is SearchEmailSuccess) {
|
||||||
} else if (failure is GetEmailByIdFailure) {
|
_searchEmailsSuccess(success);
|
||||||
openingEmail.value = false;
|
} else if (success is SearchMoreEmailSuccess) {
|
||||||
_navigationRouter = null;
|
_searchMoreEmailsSuccess(success);
|
||||||
pushAndPop(AppRoutes.unknownRoutePage);
|
} else if (success is SearchingMoreState || success is LoadingMoreState) {
|
||||||
}
|
_isLoadingMore = true;
|
||||||
},
|
} else if (success is GetEmailByIdLoading) {
|
||||||
(success) {
|
openingEmail.value = true;
|
||||||
if (success is GetAllEmailSuccess) {
|
} else if (success is GetEmailByIdSuccess) {
|
||||||
_getAllEmailSuccess(success);
|
openingEmail.value = false;
|
||||||
} else if (success is RefreshChangesAllEmailSuccess) {
|
_openEmailDetailView(success.email);
|
||||||
_refreshChangesAllEmailSuccess(success);
|
}
|
||||||
} else if (success is LoadMoreEmailsSuccess) {
|
|
||||||
_loadMoreEmailsSuccess(success);
|
|
||||||
} else if (success is SearchEmailSuccess) {
|
|
||||||
_searchEmailsSuccess(success);
|
|
||||||
} else if (success is SearchMoreEmailSuccess) {
|
|
||||||
_searchMoreEmailsSuccess(success);
|
|
||||||
} else if (success is SearchingMoreState || success is LoadingMoreState) {
|
|
||||||
_isLoadingMore = true;
|
|
||||||
} else if (success is GetEmailByIdLoading) {
|
|
||||||
openingEmail.value = true;
|
|
||||||
} else if (success is GetEmailByIdSuccess) {
|
|
||||||
openingEmail.value = false;
|
|
||||||
_openEmailDetailView(success.email);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {}
|
void handleFailureViewState(Failure failure) {
|
||||||
|
super.handleFailureViewState(failure);
|
||||||
|
if (failure is SearchEmailFailure) {
|
||||||
|
canSearchMore = false;
|
||||||
|
mailboxDashBoardController.emailsInCurrentMailbox.clear();
|
||||||
|
} else if (failure is SearchMoreEmailFailure || failure is LoadMoreEmailsFailure) {
|
||||||
|
_isLoadingMore = false;
|
||||||
|
} else if (failure is GetEmailByIdFailure) {
|
||||||
|
openingEmail.value = false;
|
||||||
|
_navigationRouter = null;
|
||||||
|
pushAndPop(AppRoutes.unknownRoutePage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onError(error) {
|
void handleErrorViewState(Object error, StackTrace stackTrace) {
|
||||||
_handleErrorGetAllOrRefreshChangesEmail(error);
|
super.handleErrorViewState(error, stackTrace);
|
||||||
|
_handleErrorGetAllOrRefreshChangesEmail(error, stackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _registerObxStreamListener() {
|
void _registerObxStreamListener() {
|
||||||
@@ -337,13 +334,13 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
_searchEmail();
|
_searchEmail();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleErrorGetAllOrRefreshChangesEmail(dynamic error) async {
|
void _handleErrorGetAllOrRefreshChangesEmail(Object error, StackTrace stackTrace) async {
|
||||||
logError('ThreadController::_handleErrorGetAllOrRefreshChangesEmail():Error: $error');
|
logError('ThreadController::_handleErrorGetAllOrRefreshChangesEmail():Error: $error');
|
||||||
if (error is CannotCalculateChangesMethodResponseException) {
|
if (error is CannotCalculateChangesMethodResponseException) {
|
||||||
await cachingManager.clearEmailCache();
|
await cachingManager.clearEmailCache();
|
||||||
_getAllEmailAction();
|
_getAllEmailAction();
|
||||||
} else {
|
} else {
|
||||||
super.onError(error);
|
super.onError(error, stackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -340,12 +340,8 @@ class UploadController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onDone() {
|
void handleFailureViewState(Failure failure) async {
|
||||||
viewState.value.fold(_handleFailureViewState, _handleSuccessViewState);
|
super.handleFailureViewState(failure);
|
||||||
}
|
|
||||||
|
|
||||||
void _handleFailureViewState(Failure failure) async {
|
|
||||||
logError('UploadController::_handleFailureViewState():failure: $failure');
|
|
||||||
if (failure is UploadAttachmentFailure) {
|
if (failure is UploadAttachmentFailure) {
|
||||||
if (failure.isInline) {
|
if (failure.isInline) {
|
||||||
if (currentContext != null && currentOverlayContext != null) {
|
if (currentContext != null && currentOverlayContext != null) {
|
||||||
@@ -367,8 +363,9 @@ class UploadController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleSuccessViewState(Success success) async {
|
@override
|
||||||
log('UploadController::_handleSuccessViewState():success: $success');
|
void handleSuccessViewState(Success success) async {
|
||||||
|
super.handleSuccessViewState(success);
|
||||||
if (success is UploadAttachmentSuccess) {
|
if (success is UploadAttachmentSuccess) {
|
||||||
if (success.isInline) {
|
if (success.isInline) {
|
||||||
_uploadingStateInlineFiles.add(success.uploadAttachment.toUploadFileState());
|
_uploadingStateInlineFiles.add(success.uploadAttachment.toUploadFileState());
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ abstract class RemoteException with EquatableMixin implements Exception {
|
|||||||
static const internalServerError = 'Internal Server Error';
|
static const internalServerError = 'Internal Server Error';
|
||||||
static const noNetworkError = 'No network error';
|
static const noNetworkError = 'No network error';
|
||||||
static const badCredentials = 'Bad credentials';
|
static const badCredentials = 'Bad credentials';
|
||||||
|
static const socketException = 'Socket exception';
|
||||||
|
|
||||||
final String? message;
|
final String? message;
|
||||||
final int? code;
|
final int? code;
|
||||||
@@ -36,6 +37,13 @@ class ConnectError extends RemoteException {
|
|||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SocketError extends RemoteException {
|
||||||
|
const SocketError() : super(message: RemoteException.socketException);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
class InternalServerError extends RemoteException {
|
class InternalServerError extends RemoteException {
|
||||||
const InternalServerError() : super(message: RemoteException.internalServerError);
|
const InternalServerError() : super(message: RemoteException.internalServerError);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:get/get_connect/http/src/status/http_status.dart';
|
import 'package:get/get_connect/http/src/status/http_status.dart';
|
||||||
@@ -20,7 +22,7 @@ class RemoteExceptionThrower extends ExceptionThrower {
|
|||||||
throw const NoNetworkError();
|
throw const NoNetworkError();
|
||||||
} else {
|
} else {
|
||||||
if (error is DioError) {
|
if (error is DioError) {
|
||||||
logError('RemoteExceptionThrower::throwException():type: ${error.type} | response: ${error.response}');
|
logError('RemoteExceptionThrower::throwException():type: ${error.type} | response: ${error.response} | error: ${error.error}');
|
||||||
switch (error.type) {
|
switch (error.type) {
|
||||||
case DioErrorType.connectionTimeout:
|
case DioErrorType.connectionTimeout:
|
||||||
throw const ConnectError();
|
throw const ConnectError();
|
||||||
@@ -31,6 +33,8 @@ class RemoteExceptionThrower extends ExceptionThrower {
|
|||||||
throw BadGateway();
|
throw BadGateway();
|
||||||
} else if (error.response?.statusCode == HttpStatus.unauthorized) {
|
} else if (error.response?.statusCode == HttpStatus.unauthorized) {
|
||||||
throw const BadCredentialsException();
|
throw const BadCredentialsException();
|
||||||
|
} else if (error.error is SocketException) {
|
||||||
|
throw const SocketError();
|
||||||
} else {
|
} else {
|
||||||
throw UnknownError(
|
throw UnknownError(
|
||||||
code: error.response?.statusCode,
|
code: error.response?.statusCode,
|
||||||
|
|||||||
Reference in New Issue
Block a user