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) {
if (success.listVacationResponse.isNotEmpty) {
if (currentContext != null && currentOverlayContext != null) {
if (!success.isAuto &&
currentContext != null &&
currentOverlayContext != null) {
appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully);
AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully,
);
}
vacationResponse.value = success.listVacationResponse.first;
log('MailboxDashBoardController::_handleUpdateVacationSuccess(): $vacationResponse');
@@ -6,11 +6,12 @@ class LoadingUpdateVacation extends UIState {}
class UpdateVacationSuccess extends UIState {
final List<VacationResponse> listVacationResponse;
final bool isAuto;
UpdateVacationSuccess(this.listVacationResponse);
UpdateVacationSuccess(this.listVacationResponse, this.isAuto);
@override
List<Object?> get props => [listVacationResponse];
List<Object?> get props => [listVacationResponse, isAuto];
}
class UpdateVacationFailure extends FeatureFailure {
@@ -13,11 +13,18 @@ class UpdateVacationInteractor {
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 {
yield Right<Failure, Success>(LoadingUpdateVacation());
final listVacationResponse = await vacationRepository.updateVacation(accountId, vacationResponse);
yield Right<Failure, Success>(UpdateVacationSuccess(listVacationResponse));
yield Right<Failure, Success>(UpdateVacationSuccess(
listVacationResponse,
isAuto,
));
} catch (exception) {
yield Left<Failure, Success>(UpdateVacationFailure(exception));
}
@@ -16,6 +16,6 @@ extension HandleVacationResponseExtension on ManageAccountDashBoardController {
}
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) {
consumeState(_updateVacationInteractor!.execute(
accountId.value!,
vacation.clearAllExceptHtmlBody(),
isAuto: isAuto,
));
} else {
consumeState(
@@ -304,11 +308,13 @@ class ManageAccountDashBoardController extends ReloadableController
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
if (success.listVacationResponse.isNotEmpty &&
!success.isAuto &&
currentContext != null &&
currentOverlayContext != null) {
appToast.showToastSuccessMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully);
AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully,
);
}
setUpVacation(success.listVacationResponse.firstOrNull);
}
@@ -42,15 +42,17 @@ class SettingsView extends GetWidget<SettingsController> {
Obx(() {
final dashboard = controller.manageAccountDashboardController;
final vacation = dashboard.vacationResponse.value;
final isWebDesktop = controller.responsiveUtils.isWebDesktop(context);
final isWebDesktopResponsive = controller
.responsiveUtils
.isWebDesktop(context);
if (vacation?.vacationResponderIsValid == true) {
return VacationNotificationMessageWidget(
margin: EdgeInsetsDirectional.only(
start: 12,
end: 12,
top: isWebDesktop ? 8 : 0,
bottom: isWebDesktop ? 0 : 16,
top: isWebDesktopResponsive ? 8 : 0,
bottom: isWebDesktopResponsive ? 0 : 16,
),
fromAccountDashBoard: true,
vacationResponse: vacation!,
@@ -65,8 +67,8 @@ class SettingsView extends GetWidget<SettingsController> {
margin: EdgeInsetsDirectional.only(
start: 12,
end: 12,
top: isWebDesktop ? 8 : 0,
bottom: isWebDesktop ? 0 : 16,
top: isWebDesktopResponsive ? 8 : 0,
bottom: isWebDesktopResponsive ? 0 : 16,
),
fromAccountDashBoard: true,
vacationResponse: vacation!,
@@ -245,6 +245,7 @@ class VacationController extends BaseController {
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
if (success.listVacationResponse.isNotEmpty &&
!success.isAuto &&
currentOverlayContext != null &&
currentContext != null) {
appToast.showToastSuccessMessage(