TF-4069 Do not show toast message when disable vacation automatically

This commit is contained in:
dab246
2025-10-14 15:30:13 +07:00
committed by Dat H. Pham
parent d6606aeb48
commit e04b88f87c
7 changed files with 34 additions and 14 deletions
@@ -2062,10 +2062,13 @@ class MailboxDashBoardController extends ReloadableController
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) { void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
if (success.listVacationResponse.isNotEmpty) { if (success.listVacationResponse.isNotEmpty) {
if (currentContext != null && currentOverlayContext != null) { if (!success.isAuto &&
currentContext != null &&
currentOverlayContext != null) {
appToast.showToastSuccessMessage( appToast.showToastSuccessMessage(
currentOverlayContext!, currentOverlayContext!,
AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully); AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully,
);
} }
vacationResponse.value = success.listVacationResponse.first; vacationResponse.value = success.listVacationResponse.first;
log('MailboxDashBoardController::_handleUpdateVacationSuccess(): $vacationResponse'); log('MailboxDashBoardController::_handleUpdateVacationSuccess(): $vacationResponse');
@@ -6,11 +6,12 @@ class LoadingUpdateVacation extends UIState {}
class UpdateVacationSuccess extends UIState { class UpdateVacationSuccess extends UIState {
final List<VacationResponse> listVacationResponse; final List<VacationResponse> listVacationResponse;
final bool isAuto;
UpdateVacationSuccess(this.listVacationResponse); UpdateVacationSuccess(this.listVacationResponse, this.isAuto);
@override @override
List<Object?> get props => [listVacationResponse]; List<Object?> get props => [listVacationResponse, isAuto];
} }
class UpdateVacationFailure extends FeatureFailure { class UpdateVacationFailure extends FeatureFailure {
@@ -13,11 +13,18 @@ class UpdateVacationInteractor {
UpdateVacationInteractor(this.vacationRepository); UpdateVacationInteractor(this.vacationRepository);
Stream<Either<Failure, Success>> execute(AccountId accountId, VacationResponse vacationResponse) async* { Stream<Either<Failure, Success>> execute(
AccountId accountId,
VacationResponse vacationResponse,
{bool isAuto = false}
) async* {
try { try {
yield Right<Failure, Success>(LoadingUpdateVacation()); yield Right<Failure, Success>(LoadingUpdateVacation());
final listVacationResponse = await vacationRepository.updateVacation(accountId, vacationResponse); final listVacationResponse = await vacationRepository.updateVacation(accountId, vacationResponse);
yield Right<Failure, Success>(UpdateVacationSuccess(listVacationResponse)); yield Right<Failure, Success>(UpdateVacationSuccess(
listVacationResponse,
isAuto,
));
} catch (exception) { } catch (exception) {
yield Left<Failure, Success>(UpdateVacationFailure(exception)); yield Left<Failure, Success>(UpdateVacationFailure(exception));
} }
@@ -16,6 +16,6 @@ extension HandleVacationResponseExtension on ManageAccountDashBoardController {
} }
void automaticallyDeactivateVacation(VacationResponse vacationResponse) { void automaticallyDeactivateVacation(VacationResponse vacationResponse) {
disableVacationResponder(vacationResponse); disableVacationResponder(vacationResponse, isAuto: true);
} }
} }
@@ -289,11 +289,15 @@ class ManageAccountDashBoardController extends ReloadableController
} }
} }
void disableVacationResponder(VacationResponse vacation) { void disableVacationResponder(
VacationResponse vacation, {
bool isAuto = false,
}) {
if (accountId.value != null && _updateVacationInteractor != null) { if (accountId.value != null && _updateVacationInteractor != null) {
consumeState(_updateVacationInteractor!.execute( consumeState(_updateVacationInteractor!.execute(
accountId.value!, accountId.value!,
vacation.clearAllExceptHtmlBody(), vacation.clearAllExceptHtmlBody(),
isAuto: isAuto,
)); ));
} else { } else {
consumeState( consumeState(
@@ -304,11 +308,13 @@ class ManageAccountDashBoardController extends ReloadableController
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) { void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
if (success.listVacationResponse.isNotEmpty && if (success.listVacationResponse.isNotEmpty &&
!success.isAuto &&
currentContext != null && currentContext != null &&
currentOverlayContext != null) { currentOverlayContext != null) {
appToast.showToastSuccessMessage( appToast.showToastSuccessMessage(
currentOverlayContext!, currentOverlayContext!,
AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully); AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully,
);
} }
setUpVacation(success.listVacationResponse.firstOrNull); setUpVacation(success.listVacationResponse.firstOrNull);
} }
@@ -42,15 +42,17 @@ class SettingsView extends GetWidget<SettingsController> {
Obx(() { Obx(() {
final dashboard = controller.manageAccountDashboardController; final dashboard = controller.manageAccountDashboardController;
final vacation = dashboard.vacationResponse.value; final vacation = dashboard.vacationResponse.value;
final isWebDesktop = controller.responsiveUtils.isWebDesktop(context); final isWebDesktopResponsive = controller
.responsiveUtils
.isWebDesktop(context);
if (vacation?.vacationResponderIsValid == true) { if (vacation?.vacationResponderIsValid == true) {
return VacationNotificationMessageWidget( return VacationNotificationMessageWidget(
margin: EdgeInsetsDirectional.only( margin: EdgeInsetsDirectional.only(
start: 12, start: 12,
end: 12, end: 12,
top: isWebDesktop ? 8 : 0, top: isWebDesktopResponsive ? 8 : 0,
bottom: isWebDesktop ? 0 : 16, bottom: isWebDesktopResponsive ? 0 : 16,
), ),
fromAccountDashBoard: true, fromAccountDashBoard: true,
vacationResponse: vacation!, vacationResponse: vacation!,
@@ -65,8 +67,8 @@ class SettingsView extends GetWidget<SettingsController> {
margin: EdgeInsetsDirectional.only( margin: EdgeInsetsDirectional.only(
start: 12, start: 12,
end: 12, end: 12,
top: isWebDesktop ? 8 : 0, top: isWebDesktopResponsive ? 8 : 0,
bottom: isWebDesktop ? 0 : 16, bottom: isWebDesktopResponsive ? 0 : 16,
), ),
fromAccountDashBoard: true, fromAccountDashBoard: true,
vacationResponse: vacation!, vacationResponse: vacation!,
@@ -245,6 +245,7 @@ class VacationController extends BaseController {
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) { void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
if (success.listVacationResponse.isNotEmpty && if (success.listVacationResponse.isNotEmpty &&
!success.isAuto &&
currentOverlayContext != null && currentOverlayContext != null &&
currentContext != null) { currentContext != null) {
appToast.showToastSuccessMessage( appToast.showToastSuccessMessage(