TF-802 Disable vacation responder in notification message
This commit is contained in:
@@ -70,7 +70,8 @@ class EmailView extends GetWidget<EmailController> with NetworkConnectionMixin {
|
||||
child: VacationNotificationMessageWidget(
|
||||
radius: 0,
|
||||
margin: EdgeInsets.zero,
|
||||
vacationResponse: controller.mailboxDashBoardController.vacationResponse.value!),
|
||||
vacationResponse: controller.mailboxDashBoardController.vacationResponse.value!,
|
||||
action: () => controller.mailboxDashBoardController.disableVacationResponder()),
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
|
||||
@@ -74,6 +74,7 @@ import 'package:tmail_ui_user/features/manage_account/data/repository/manage_acc
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/repository/manage_account_repository.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/get_all_vacation_interactor.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/update_vacation_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/datasource/thread_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/datasource_impl/local_thread_datasource_impl.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/datasource_impl/thread_datasource_impl.dart';
|
||||
@@ -110,6 +111,7 @@ class MailboxDashBoardBindings extends BaseBindings {
|
||||
Get.find<MarkAsMailboxReadInteractor>(),
|
||||
Get.find<GetComposerCacheOnWebInteractor>(),
|
||||
Get.find<GetAllVacationInteractor>(),
|
||||
Get.find<UpdateVacationInteractor>(),
|
||||
));
|
||||
Get.put(AdvancedFilterController());
|
||||
}
|
||||
@@ -192,6 +194,7 @@ class MailboxDashBoardBindings extends BaseBindings {
|
||||
Get.lazyPut(() => SaveComposerCacheOnWebInteractor(Get.find<ComposerCacheRepository>()));
|
||||
Get.lazyPut(() => RemoveComposerCacheOnWebInteractor(Get.find<ComposerCacheRepository>()));
|
||||
Get.lazyPut(() => GetAllVacationInteractor(Get.find<ManageAccountRepository>()));
|
||||
Get.lazyPut(() => UpdateVacationInteractor(Get.find<ManageAccountRepository>()));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
+29
@@ -45,8 +45,11 @@ import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/comp
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/download/download_task_state.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/search/quick_search_filter.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/state/get_all_vacation_state.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/state/update_vacation_state.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/get_all_vacation_interactor.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/update_vacation_interactor.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/manage_account_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||
@@ -75,6 +78,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
final MarkAsMailboxReadInteractor _markAsMailboxReadInteractor;
|
||||
final GetComposerCacheOnWebInteractor _getEmailCacheOnWebInteractor;
|
||||
final GetAllVacationInteractor _getAllVacationInteractor;
|
||||
final UpdateVacationInteractor _updateVacationInteractor;
|
||||
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final selectedMailbox = Rxn<PresentationMailbox>();
|
||||
@@ -112,6 +116,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
this._markAsMailboxReadInteractor,
|
||||
this._getEmailCacheOnWebInteractor,
|
||||
this._getAllVacationInteractor,
|
||||
this._updateVacationInteractor,
|
||||
) : super(logoutOidcInteractor,
|
||||
deleteAuthorityOidcInteractor,
|
||||
getAuthenticatedAccountInteractor);
|
||||
@@ -221,6 +226,8 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
if (success.listVacationResponse.isNotEmpty) {
|
||||
vacationResponse.value = success.listVacationResponse.first;
|
||||
}
|
||||
} else if (success is UpdateVacationSuccess) {
|
||||
_handleUpdateVacationSuccess(success);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -611,6 +618,28 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
downloadController.deleteDownloadTask(taskId);
|
||||
}
|
||||
|
||||
void disableVacationResponder() {
|
||||
if (accountId.value != null) {
|
||||
final vacationDisabled = vacationResponse.value != null
|
||||
? vacationResponse.value!.copyWith(isEnabled: false)
|
||||
: VacationResponse(isEnabled: false);
|
||||
consumeState(_updateVacationInteractor.execute(accountId.value!, vacationDisabled));
|
||||
}
|
||||
}
|
||||
|
||||
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
|
||||
if (success.listVacationResponse.isNotEmpty) {
|
||||
if (currentContext != null && currentOverlayContext != null) {
|
||||
_appToast.showToastWithIcon(
|
||||
currentOverlayContext!,
|
||||
message: AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully,
|
||||
icon: _imagePaths.icChecked);
|
||||
}
|
||||
vacationResponse.value = success.listVacationResponse.first;
|
||||
log('MailboxDashBoardController::_handleUpdateVacationSuccess(): $vacationResponse');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
_emailReceiveManager.closeEmailReceiveManagerStream();
|
||||
|
||||
@@ -99,7 +99,8 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
|
||||
if (controller.vacationResponse.value?.vacationResponderIsReady == true) {
|
||||
return VacationNotificationMessageWidget(
|
||||
margin: const EdgeInsets.only(top: 16, right: 16),
|
||||
vacationResponse: controller.vacationResponse.value!);
|
||||
vacationResponse: controller.vacationResponse.value!,
|
||||
action: () => controller.disableVacationResponder());
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import 'package:tmail_ui_user/features/manage_account/data/repository/manage_acc
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/repository/manage_account_repository.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/get_all_vacation_interactor.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/update_vacation_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/language_and_region/language_and_region_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/manage_account_dashboard_controller.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/menu/manage_account_menu_bindings.dart';
|
||||
@@ -50,7 +51,8 @@ class ManageAccountDashBoardBindings extends BaseBindings {
|
||||
Get.find<LogoutOidcInteractor>(),
|
||||
Get.find<DeleteAuthorityOidcInteractor>(),
|
||||
Get.find<GetAuthenticatedAccountInteractor>(),
|
||||
Get.find<GetAllVacationInteractor>()
|
||||
Get.find<GetAllVacationInteractor>(),
|
||||
Get.find<UpdateVacationInteractor>()
|
||||
));
|
||||
}
|
||||
|
||||
@@ -94,6 +96,7 @@ class ManageAccountDashBoardBindings extends BaseBindings {
|
||||
Get.find<GetStoredTokenOidcInteractor>(),
|
||||
));
|
||||
Get.lazyPut(() => GetAllVacationInteractor(Get.find<ManageAccountRepository>()));
|
||||
Get.lazyPut(() => UpdateVacationInteractor(Get.find<ManageAccountRepository>()));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -15,18 +15,26 @@ import 'package:tmail_ui_user/features/login/domain/usecases/delete_authority_oi
|
||||
import 'package:tmail_ui_user/features/login/domain/usecases/get_authenticated_account_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/state/get_user_profile_state.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/state/get_all_vacation_state.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/state/update_vacation_state.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/get_all_vacation_interactor.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/update_vacation_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/email_rules/email_rules_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/extensions/vacation_response_extension.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/forward/forward_bindings.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/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
class ManageAccountDashBoardController extends ReloadableController {
|
||||
|
||||
final _appToast = Get.find<AppToast>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
|
||||
final GetAllVacationInteractor _getAllVacationInteractor;
|
||||
final UpdateVacationInteractor _updateVacationInteractor;
|
||||
|
||||
final menuDrawerKey = GlobalKey<ScaffoldState>(debugLabel: 'manage_account');
|
||||
|
||||
@@ -42,6 +50,7 @@ class ManageAccountDashBoardController extends ReloadableController {
|
||||
DeleteAuthorityOidcInteractor deleteAuthorityOidcInteractor,
|
||||
GetAuthenticatedAccountInteractor getAuthenticatedAccountInteractor,
|
||||
this._getAllVacationInteractor,
|
||||
this._updateVacationInteractor,
|
||||
) : super(logoutOidcInteractor,
|
||||
deleteAuthorityOidcInteractor,
|
||||
getAuthenticatedAccountInteractor);
|
||||
@@ -64,6 +73,8 @@ class ManageAccountDashBoardController extends ReloadableController {
|
||||
if (success.listVacationResponse.isNotEmpty) {
|
||||
vacationResponse.value = success.listVacationResponse.first;
|
||||
}
|
||||
} else if (success is UpdateVacationSuccess) {
|
||||
_handleUpdateVacationSuccess(success);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -162,4 +173,25 @@ class ManageAccountDashBoardController extends ReloadableController {
|
||||
|
||||
bool checkAvailableForwardInSession() => sessionCurrent.value?.capabilities.containsKey(capabilityForward) ?? false;
|
||||
|
||||
void disableVacationResponder() {
|
||||
if (accountId.value != null) {
|
||||
final vacationDisabled = vacationResponse.value != null
|
||||
? vacationResponse.value!.copyWith(isEnabled: false)
|
||||
: VacationResponse(isEnabled: false);
|
||||
consumeState(_updateVacationInteractor.execute(accountId.value!, vacationDisabled));
|
||||
}
|
||||
}
|
||||
|
||||
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
|
||||
if (success.listVacationResponse.isNotEmpty) {
|
||||
if (currentContext != null && currentOverlayContext != null) {
|
||||
_appToast.showToastWithIcon(
|
||||
currentOverlayContext!,
|
||||
message: AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully,
|
||||
icon: _imagePaths.icChecked);
|
||||
}
|
||||
vacationResponse.value = success.listVacationResponse.first;
|
||||
log('ManageAccountDashBoardController::_handleUpdateVacationSuccess(): $vacationResponse');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,8 @@ class ManageAccountDashBoardView extends GetWidget<ManageAccountDashBoardControl
|
||||
top: 16,
|
||||
left: BuildUtils.isWeb ? 24 : 16,
|
||||
right: BuildUtils.isWeb ? 24 : 16),
|
||||
vacationResponse: controller.vacationResponse.value!);
|
||||
vacationResponse: controller.vacationResponse.value!,
|
||||
action: () => controller.disableVacationResponder());
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
@@ -116,7 +117,8 @@ class ManageAccountDashBoardView extends GetWidget<ManageAccountDashBoardControl
|
||||
left: BuildUtils.isWeb ? 24 : 16,
|
||||
right: BuildUtils.isWeb ? 24 : 16,
|
||||
top: BuildUtils.isWeb ? 16 : 0),
|
||||
vacationResponse: controller.vacationResponse.value!);
|
||||
vacationResponse: controller.vacationResponse.value!,
|
||||
action: () => controller.disableVacationResponder());
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ class VacationController extends BaseController {
|
||||
final TextEditingController messageBodyEditorController = TextEditingController();
|
||||
|
||||
VacationResponse? currentVacation;
|
||||
late Worker vacationWorker;
|
||||
|
||||
VacationController(
|
||||
this._getAllVacationInteractor,
|
||||
@@ -42,6 +43,12 @@ class VacationController extends BaseController {
|
||||
this._verifyNameInteractor
|
||||
);
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
_initWorker();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
_getAllVacation();
|
||||
@@ -65,6 +72,17 @@ class VacationController extends BaseController {
|
||||
@override
|
||||
void onError(error) {}
|
||||
|
||||
void _initWorker() {
|
||||
vacationWorker = ever(_accountDashBoardController.vacationResponse, (vacation) {
|
||||
if (vacation is VacationResponse) {
|
||||
currentVacation = vacation;
|
||||
final newVacationPresentation = currentVacation?.toVacationPresentation();
|
||||
vacationPresentation.value = newVacationPresentation ?? VacationPresentation.initialize();
|
||||
messageBodyEditorController.text = newVacationPresentation?.messageBody ?? '';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _getAllVacation() {
|
||||
final accountId = _accountDashBoardController.accountId.value;
|
||||
if (accountId != null) {
|
||||
@@ -273,6 +291,7 @@ class VacationController extends BaseController {
|
||||
@override
|
||||
void onClose() {
|
||||
messageBodyEditorController.dispose();
|
||||
vacationWorker.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,8 @@ class ThreadView extends GetWidget<ThreadController> with AppLoaderMixin,
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: VacationNotificationMessageWidget(
|
||||
vacationResponse: controller.mailboxDashBoardController.vacationResponse.value!),
|
||||
vacationResponse: controller.mailboxDashBoardController.vacationResponse.value!,
|
||||
action: () => controller.mailboxDashBoardController.disableVacationResponder()),
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"@@last_modified": "2022-08-18T14:30:25.186365",
|
||||
"@@last_modified": "2022-08-18T16:16:05.548805",
|
||||
"initializing_data": "Initializing data...",
|
||||
"@initializing_data": {
|
||||
"type": "text",
|
||||
@@ -2011,5 +2011,11 @@
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"yourVacationResponderIsDisabledSuccessfully": "Your vacation responder is disabled successfully",
|
||||
"@yourVacationResponderIsDisabledSuccessfully": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
}
|
||||
}
|
||||
@@ -2085,4 +2085,11 @@ class AppLocalizations {
|
||||
name: 'disable',
|
||||
);
|
||||
}
|
||||
|
||||
String get yourVacationResponderIsDisabledSuccessfully {
|
||||
return Intl.message(
|
||||
'Your vacation responder is disabled successfully',
|
||||
name: 'yourVacationResponderIsDisabledSuccessfully',
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user