Skip to content

Commit 5d2b5e1

Browse files
committed
TF-4069 Do not show toast message when disable vacation automatically
1 parent 93b4bcb commit 5d2b5e1

File tree

7 files changed

+34
-14
lines changed

7 files changed

+34
-14
lines changed

lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,10 +2067,13 @@ class MailboxDashBoardController extends ReloadableController
20672067

20682068
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
20692069
if (success.listVacationResponse.isNotEmpty) {
2070-
if (currentContext != null && currentOverlayContext != null) {
2070+
if (!success.isAuto &&
2071+
currentContext != null &&
2072+
currentOverlayContext != null) {
20712073
appToast.showToastSuccessMessage(
20722074
currentOverlayContext!,
2073-
AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully);
2075+
AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully,
2076+
);
20742077
}
20752078
vacationResponse.value = success.listVacationResponse.first;
20762079
log('MailboxDashBoardController::_handleUpdateVacationSuccess(): $vacationResponse');

lib/features/manage_account/domain/state/update_vacation_state.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ class LoadingUpdateVacation extends UIState {}
66

77
class UpdateVacationSuccess extends UIState {
88
final List<VacationResponse> listVacationResponse;
9+
final bool isAuto;
910

10-
UpdateVacationSuccess(this.listVacationResponse);
11+
UpdateVacationSuccess(this.listVacationResponse, this.isAuto);
1112

1213
@override
13-
List<Object?> get props => [listVacationResponse];
14+
List<Object?> get props => [listVacationResponse, isAuto];
1415
}
1516

1617
class UpdateVacationFailure extends FeatureFailure {

lib/features/manage_account/domain/usecases/update_vacation_interactor.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ class UpdateVacationInteractor {
1313

1414
UpdateVacationInteractor(this.vacationRepository);
1515

16-
Stream<Either<Failure, Success>> execute(AccountId accountId, VacationResponse vacationResponse) async* {
16+
Stream<Either<Failure, Success>> execute(
17+
AccountId accountId,
18+
VacationResponse vacationResponse,
19+
{bool isAuto = false}
20+
) async* {
1721
try {
1822
yield Right<Failure, Success>(LoadingUpdateVacation());
1923
final listVacationResponse = await vacationRepository.updateVacation(accountId, vacationResponse);
20-
yield Right<Failure, Success>(UpdateVacationSuccess(listVacationResponse));
24+
yield Right<Failure, Success>(UpdateVacationSuccess(
25+
listVacationResponse,
26+
isAuto,
27+
));
2128
} catch (exception) {
2229
yield Left<Failure, Success>(UpdateVacationFailure(exception));
2330
}

lib/features/manage_account/presentation/extensions/handle_vacation_response_extension.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ extension HandleVacationResponseExtension on ManageAccountDashBoardController {
1616
}
1717

1818
void automaticallyDeactivateVacation(VacationResponse vacationResponse) {
19-
disableVacationResponder(vacationResponse);
19+
disableVacationResponder(vacationResponse, isAuto: true);
2020
}
2121
}

lib/features/manage_account/presentation/manage_account_dashboard_controller.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,15 @@ class ManageAccountDashBoardController extends ReloadableController
289289
}
290290
}
291291

292-
void disableVacationResponder(VacationResponse vacation) {
292+
void disableVacationResponder(
293+
VacationResponse vacation, {
294+
bool isAuto = false,
295+
}) {
293296
if (accountId.value != null && _updateVacationInteractor != null) {
294297
consumeState(_updateVacationInteractor!.execute(
295298
accountId.value!,
296299
vacation.clearAllExceptHtmlBody(),
300+
isAuto: isAuto,
297301
));
298302
} else {
299303
consumeState(
@@ -304,11 +308,13 @@ class ManageAccountDashBoardController extends ReloadableController
304308

305309
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
306310
if (success.listVacationResponse.isNotEmpty &&
311+
!success.isAuto &&
307312
currentContext != null &&
308313
currentOverlayContext != null) {
309314
appToast.showToastSuccessMessage(
310315
currentOverlayContext!,
311-
AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully);
316+
AppLocalizations.of(currentContext!).yourVacationResponderIsDisabledSuccessfully,
317+
);
312318
}
313319
setUpVacation(success.listVacationResponse.firstOrNull);
314320
}

lib/features/manage_account/presentation/menu/settings/settings_view.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,17 @@ class SettingsView extends GetWidget<SettingsController> {
4242
Obx(() {
4343
final dashboard = controller.manageAccountDashboardController;
4444
final vacation = dashboard.vacationResponse.value;
45-
final isWebDesktop = controller.responsiveUtils.isWebDesktop(context);
45+
final isWebDesktopResponsive = controller
46+
.responsiveUtils
47+
.isWebDesktop(context);
4648

4749
if (vacation?.vacationResponderIsValid == true) {
4850
return VacationNotificationMessageWidget(
4951
margin: EdgeInsetsDirectional.only(
5052
start: 12,
5153
end: 12,
52-
top: isWebDesktop ? 8 : 0,
53-
bottom: isWebDesktop ? 0 : 16,
54+
top: isWebDesktopResponsive ? 8 : 0,
55+
bottom: isWebDesktopResponsive ? 0 : 16,
5456
),
5557
fromAccountDashBoard: true,
5658
vacationResponse: vacation!,
@@ -65,8 +67,8 @@ class SettingsView extends GetWidget<SettingsController> {
6567
margin: EdgeInsetsDirectional.only(
6668
start: 12,
6769
end: 12,
68-
top: isWebDesktop ? 8 : 0,
69-
bottom: isWebDesktop ? 0 : 16,
70+
top: isWebDesktopResponsive ? 8 : 0,
71+
bottom: isWebDesktopResponsive ? 0 : 16,
7072
),
7173
fromAccountDashBoard: true,
7274
vacationResponse: vacation!,

lib/features/manage_account/presentation/vacation/vacation_controller.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ class VacationController extends BaseController {
245245

246246
void _handleUpdateVacationSuccess(UpdateVacationSuccess success) {
247247
if (success.listVacationResponse.isNotEmpty &&
248+
!success.isAuto &&
248249
currentOverlayContext != null &&
249250
currentContext != null) {
250251
appToast.showToastSuccessMessage(

0 commit comments

Comments
 (0)