TF-4102 Don't display free-busy on IMIP responses (accepted, tentative, rejected)

This commit is contained in:
dab246
2025-10-15 15:17:12 +07:00
committed by Dat H. Pham
parent 51b85c8b79
commit 474a8806e2
7 changed files with 37 additions and 16 deletions
@@ -19,6 +19,7 @@ import 'package:tmail_ui_user/features/base/widget/optional_expanded.dart';
import 'package:tmail_ui_user/features/base/widget/optional_scroll.dart';
import 'package:tmail_ui_user/features/email/presentation/controller/single_email_controller.dart';
import 'package:tmail_ui_user/features/email/presentation/extensions/calendar_event_extension.dart';
import 'package:tmail_ui_user/features/email/presentation/extensions/validate_display_free_busy_message_extension.dart';
import 'package:tmail_ui_user/features/email/presentation/styles/email_view_styles.dart';
import 'package:tmail_ui_user/features/email/presentation/utils/email_action_reactor/email_action_reactor.dart';
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/calendar_event_action_banner_widget.dart';
@@ -315,7 +316,7 @@ class EmailView extends GetWidget<SingleEmailController> {
ownEmailAddress: controller.ownEmailAddress,
onMailtoAttendeesAction: controller.handleMailToAttendees,
openEmailAddressDetailAction: (_, emailAddress) => controller.openEmailAddressDialog(emailAddress),
isFree: controller.isCalendarEventFree,
isFreeBusyEnabled: controller.isFreeBusyEnabled(emailAddressSender ?? []),
listEmailAddressSender: emailAddressSender ?? [],
isPortraitMobile: controller
.responsiveUtils
@@ -437,6 +437,17 @@ extension CalendarEventExtension on CalendarEvent {
}
}
bool isIMIPResponsesAvailable(List<String> listEmailAddressSender) {
final participationStatus = findAttendeeHasUpdatedStatus(
listEmailAddressSender,
)?.participationStatus?.value;
return method == EventMethod.reply &&
(participationStatus == acceptedParticipationStatus ||
participationStatus == tentativeParticipationStatus ||
participationStatus == declinedParticipationStatus);
}
CalendarEvent copyWith({
EventId? eventId,
String? title,
@@ -0,0 +1,9 @@
import 'package:tmail_ui_user/features/email/presentation/controller/single_email_controller.dart';
import 'package:tmail_ui_user/features/email/presentation/extensions/calendar_event_extension.dart';
extension ValidateDisplayFreeBusyMessageExtension on SingleEmailController {
bool isFreeBusyEnabled(List<String> listEmailAddressSender) {
return !isCalendarEventFree &&
calendarEvent?.isIMIPResponsesAvailable(listEmailAddressSender) != true;
}
}
@@ -31,7 +31,7 @@ class CalendarEventInformationWidget extends StatelessWidget {
final AttendanceStatus? attendanceStatus;
final OnMailtoAttendeesAction? onMailtoAttendeesAction;
final OnOpenEmailAddressDetailAction? openEmailAddressDetailAction;
final bool isFree;
final bool isFreeBusyEnabled;
final List<String> listEmailAddressSender;
final String ownEmailAddress;
final bool isPortraitMobile;
@@ -41,7 +41,7 @@ class CalendarEventInformationWidget extends StatelessWidget {
required this.calendarEvent,
required this.onCalendarEventReplyActionClick,
required this.calendarEventReplying,
required this.isFree,
required this.isFreeBusyEnabled,
required this.ownEmailAddress,
this.onOpenNewTabAction,
this.onOpenComposerAction,
@@ -233,7 +233,7 @@ class CalendarEventInformationWidget extends StatelessWidget {
padding: const EdgeInsets.only(top: CalendarEventInformationWidgetStyles.fieldTopPadding),
child: EventTimeInformationWidget(
timeEvent: dateTimeEvent,
isFree: isFree,
isFreeBusyEnabled: isFreeBusyEnabled,
),
);
} else {
@@ -13,12 +13,12 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
class EventTimeInformationWidget extends StatelessWidget {
final String timeEvent;
final bool isFree;
final bool isFreeBusyEnabled;
const EventTimeInformationWidget({
super.key,
required this.timeEvent,
required this.isFree,
required this.isFreeBusyEnabled,
});
@override
@@ -51,7 +51,7 @@ class EventTimeInformationWidget extends StatelessWidget {
color: EventTimeInformationWidgetStyles.valueColor
),
)),
if (!isFree)
if (isFreeBusyEnabled)
...[
const SizedBox(width: EventTimeInformationWidgetStyles.horizontalSpacing),
Tooltip(
@@ -38,7 +38,7 @@ void main() {
calendarEvent: calendarEvent,
onCalendarEventReplyActionClick: (_) {},
calendarEventReplying: false,
isFree: false,
isFreeBusyEnabled: false,
ownEmailAddress: ownEmail,
),
),
@@ -81,7 +81,7 @@ void main() {
calendarEvent: calendarEvent,
onCalendarEventReplyActionClick: (_) {},
calendarEventReplying: false,
isFree: false,
isFreeBusyEnabled: false,
ownEmailAddress: ownEmail,
),
),
@@ -121,7 +121,7 @@ void main() {
calendarEvent: calendarEvent,
onCalendarEventReplyActionClick: (_) {},
calendarEventReplying: false,
isFree: false,
isFreeBusyEnabled: false,
ownEmailAddress: ownEmail,
),
),
@@ -21,21 +21,21 @@ void main() {
group('EventTimeInformationWidget tests', () {
Widget makeTestableWidget({
required String timeEvent,
required bool isFree,
required bool isFreeBusyEnabled,
}) {
return WidgetFixtures.makeTestableWidget(
child: EventTimeInformationWidget(
timeEvent: timeEvent,
isFree: isFree,
isFreeBusyEnabled: isFreeBusyEnabled,
),
);
}
testWidgets('should show error icon with tooltip when isFree is false', (tester) async {
testWidgets('should show error icon with tooltip when isFreeBusyEnabled is true', (tester) async {
// arrange
final widget = makeTestableWidget(
timeEvent: '10:00 AM - 11:00 AM',
isFree: false,
isFreeBusyEnabled: true,
);
// act
@@ -51,11 +51,11 @@ void main() {
expect(find.byType(Tooltip), findsOneWidget);
});
testWidgets('should not show error icon when isFree is true', (tester) async {
testWidgets('should not show error icon when isFreeBusyEnabled is false', (tester) async {
// arrange
final widget = makeTestableWidget(
timeEvent: '10:00 AM - 11:00 AM',
isFree: true,
isFreeBusyEnabled: false,
);
// act