TF-2078 Implement get calendar event action in domain & data layer

(cherry picked from commit 6c372d57cfebf31e776f071b514e71c637b44257)
This commit is contained in:
dab246
2023-08-10 18:12:58 +07:00
committed by Dat Vu
parent 86a3ba8d89
commit bc8c5336bd
8 changed files with 131 additions and 8 deletions
@@ -3,6 +3,8 @@ 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/calendar/calendar_event.dart';
import 'package:tmail_ui_user/features/email/domain/model/event_action.dart';
import 'package:tmail_ui_user/features/email/domain/repository/calendar_event_repository.dart';
import 'package:tmail_ui_user/features/email/domain/state/parse_calendar_event_state.dart';
@@ -11,11 +13,26 @@ class ParseCalendarEventInteractor {
ParseCalendarEventInteractor(this._calendarEventRepository);
Stream<Either<Failure, Success>> execute(AccountId accountId, Set<Id> blobIds) async* {
Stream<Either<Failure, Success>> execute(
AccountId accountId,
Set<Id> blobIds,
String emailContents
) async* {
try {
yield Right(ParseCalendarEventLoading());
final calendarEventList = await _calendarEventRepository.parse(accountId, blobIds);
yield Right(ParseCalendarEventSuccess(calendarEventList));
final result = await Future.wait(
[
_calendarEventRepository.parse(accountId, blobIds),
_calendarEventRepository.getListEventAction(emailContents),
],
eagerError: true
);
final calendarEventList = result.first as List<CalendarEvent>;
final eventActionList = result.last as List<EventAction>;
yield Right(ParseCalendarEventSuccess(calendarEventList, eventActionList));
} catch (e) {
yield Left(ParseCalendarEventFailure(e));
}