TF-802 Disable vacation responder in setting
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/utc_date.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/vacation/vacation_response.dart';
|
import 'package:jmap_dart_client/jmap/mail/vacation/vacation_response.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/vacation/vacation_presentation.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/model/vacation/vacation_presentation.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/vacation/vacation_responder_status.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/model/vacation/vacation_responder_status.dart';
|
||||||
@@ -40,4 +41,22 @@ extension VacationResponseExtension on VacationResponse {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VacationResponse copyWith({
|
||||||
|
bool? isEnabled,
|
||||||
|
UTCDate? fromDate,
|
||||||
|
UTCDate? toDate,
|
||||||
|
String? subject,
|
||||||
|
String? textBody,
|
||||||
|
String? htmlBody
|
||||||
|
}) {
|
||||||
|
return VacationResponse(
|
||||||
|
isEnabled: isEnabled ?? this.isEnabled,
|
||||||
|
fromDate: fromDate ?? this.fromDate,
|
||||||
|
toDate: toDate ?? this.toDate,
|
||||||
|
subject: subject ?? this.subject,
|
||||||
|
textBody: textBody ?? this.textBody,
|
||||||
|
htmlBody: htmlBody ?? this.htmlBody
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,8 @@ class VacationController extends BaseController {
|
|||||||
|
|
||||||
final TextEditingController messageBodyEditorController = TextEditingController();
|
final TextEditingController messageBodyEditorController = TextEditingController();
|
||||||
|
|
||||||
|
VacationResponse? currentVacation;
|
||||||
|
|
||||||
VacationController(
|
VacationController(
|
||||||
this._getAllVacationInteractor,
|
this._getAllVacationInteractor,
|
||||||
this._updateVacationInteractor,
|
this._updateVacationInteractor,
|
||||||
@@ -72,12 +74,14 @@ class VacationController extends BaseController {
|
|||||||
|
|
||||||
void _handleGetAllVacationSuccess(GetAllVacationSuccess success) {
|
void _handleGetAllVacationSuccess(GetAllVacationSuccess success) {
|
||||||
if (success.listVacationResponse.isNotEmpty) {
|
if (success.listVacationResponse.isNotEmpty) {
|
||||||
final currentVacation = success.listVacationResponse.first;
|
currentVacation = success.listVacationResponse.first;
|
||||||
log('VacationController::_handleGetAllVacationSuccess(): $currentVacation');
|
log('VacationController::_handleGetAllVacationSuccess(): $currentVacation');
|
||||||
|
|
||||||
final newVacationPresentation = currentVacation.toVacationPresentation();
|
if (currentVacation != null) {
|
||||||
vacationPresentation.value = newVacationPresentation;
|
final newVacationPresentation = currentVacation!.toVacationPresentation();
|
||||||
messageBodyEditorController.text = newVacationPresentation.messageBody ?? '';
|
vacationPresentation.value = newVacationPresentation;
|
||||||
|
messageBodyEditorController.text = newVacationPresentation.messageBody ?? '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,6 +233,12 @@ class VacationController extends BaseController {
|
|||||||
final newVacationResponse = newVacationPresentation.toVacationResponse();
|
final newVacationResponse = newVacationPresentation.toVacationResponse();
|
||||||
log('VacationController::saveVacation(): newVacationResponse: $newVacationResponse');
|
log('VacationController::saveVacation(): newVacationResponse: $newVacationResponse');
|
||||||
_updateVacationAction(newVacationResponse);
|
_updateVacationAction(newVacationResponse);
|
||||||
|
} else {
|
||||||
|
final vacationDisabled = currentVacation != null
|
||||||
|
? currentVacation!.copyWith(isEnabled: false)
|
||||||
|
: VacationResponse(isEnabled: false);
|
||||||
|
log('VacationController::saveVacation(): vacationDisabled: $vacationDisabled');
|
||||||
|
_updateVacationAction(vacationDisabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,12 +257,14 @@ class VacationController extends BaseController {
|
|||||||
message: AppLocalizations.of(currentContext!).vacationSettingSaved,
|
message: AppLocalizations.of(currentContext!).vacationSettingSaved,
|
||||||
icon: _imagePaths.icChecked);
|
icon: _imagePaths.icChecked);
|
||||||
}
|
}
|
||||||
final currentVacation = success.listVacationResponse.first;
|
currentVacation = success.listVacationResponse.first;
|
||||||
log('VacationController::_handleUpdateVacationSuccess(): $currentVacation');
|
log('VacationController::_handleUpdateVacationSuccess(): $currentVacation');
|
||||||
|
|
||||||
final newVacationPresentation = currentVacation.toVacationPresentation();
|
if (currentVacation != null) {
|
||||||
vacationPresentation.value = newVacationPresentation;
|
final newVacationPresentation = currentVacation!.toVacationPresentation();
|
||||||
messageBodyEditorController.text = newVacationPresentation.messageBody ?? '';
|
vacationPresentation.value = newVacationPresentation;
|
||||||
|
messageBodyEditorController.text = newVacationPresentation.messageBody ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
_accountDashBoardController.updateVacationResponse(currentVacation);
|
_accountDashBoardController.updateVacationResponse(currentVacation);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user