TF-3591 Implement CalendarEventCounter/accept method
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/properties/event_method.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/model/event_action.dart';
|
||||
|
||||
extension ListEventActionsExtension on List<EventActionType> {
|
||||
List<EventActionType> validActionsOfEventMethod(EventMethod? eventMethod) {
|
||||
return where((action) {
|
||||
if (eventMethod != EventMethod.counter) {
|
||||
return action != EventActionType.acceptCounter;
|
||||
}
|
||||
|
||||
return action == EventActionType.acceptCounter
|
||||
|| action == EventActionType.mailToAttendees;
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
enum EventActionType {
|
||||
yes,
|
||||
acceptCounter,
|
||||
maybe,
|
||||
no,
|
||||
mailToAttendees;
|
||||
@@ -12,6 +13,7 @@ enum EventActionType {
|
||||
String getLabelButton(BuildContext context) {
|
||||
switch(this) {
|
||||
case EventActionType.yes:
|
||||
case EventActionType.acceptCounter:
|
||||
return AppLocalizations.of(context).yes;
|
||||
case EventActionType.maybe:
|
||||
return AppLocalizations.of(context).maybe;
|
||||
@@ -26,6 +28,8 @@ enum EventActionType {
|
||||
switch(this) {
|
||||
case EventActionType.yes:
|
||||
return AppLocalizations.of(context).youWillAttendThisMeeting;
|
||||
case EventActionType.acceptCounter:
|
||||
return AppLocalizations.of(context).youAcceptedTheProposedTimeForThisMeeting;
|
||||
case EventActionType.maybe:
|
||||
return AppLocalizations.of(context).youMayAttendThisMeeting;
|
||||
case EventActionType.no:
|
||||
|
||||
@@ -28,4 +28,9 @@ abstract class CalendarEventRepository {
|
||||
Future<List<BlobCalendarEvent>> transformCalendarEventDescription(
|
||||
List<BlobCalendarEvent> blobCalendarEvents,
|
||||
TransformConfiguration transformConfiguration);
|
||||
|
||||
Future<CalendarEventAcceptResponse> acceptCounterEvent(
|
||||
AccountId accountId,
|
||||
Set<Id> blobIds,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/model/event_action.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/calendar_event_reply_state.dart';
|
||||
|
||||
class CalendarEventCounterAccepting extends LoadingState {}
|
||||
|
||||
class CalendarEventCounterAccepted extends CalendarEventReplySuccess {
|
||||
CalendarEventCounterAccepted(super.calendarEventAcceptResponse, super.emailId);
|
||||
|
||||
@override
|
||||
EventActionType getEventActionType() => EventActionType.acceptCounter;
|
||||
}
|
||||
|
||||
class CalendarEventCounterAcceptFailure extends CalendarEventReplyFailure {
|
||||
CalendarEventCounterAcceptFailure({super.exception});
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/repository/calendar_event_repository.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/calendar_event_counter_accept_state.dart';
|
||||
|
||||
class AcceptCounterCalendarEventInteractor {
|
||||
AcceptCounterCalendarEventInteractor(this._calendarEventRepository);
|
||||
|
||||
final CalendarEventRepository _calendarEventRepository;
|
||||
|
||||
Stream<Either<Failure, Success>> execute(
|
||||
AccountId accountId,
|
||||
Set<Id> blobIds,
|
||||
EmailId emailId,
|
||||
) async* {
|
||||
try {
|
||||
yield Right(CalendarEventCounterAccepting());
|
||||
final result = await _calendarEventRepository
|
||||
.acceptCounterEvent(accountId, blobIds);
|
||||
yield Right(CalendarEventCounterAccepted(result, emailId));
|
||||
} catch (e) {
|
||||
yield Left(CalendarEventCounterAcceptFailure(exception: e));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user