TF-2035 Add interactor handle parse calendar event
(cherry picked from commit c735f3ac2909138be13358e57c290f8f6440cc89)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.dart';
|
||||
|
||||
class ParseCalendarEventLoading extends LoadingState {}
|
||||
|
||||
class ParseCalendarEventSuccess extends UIState {
|
||||
|
||||
final List<CalendarEvent> calendarEventList;
|
||||
|
||||
ParseCalendarEventSuccess(this.calendarEventList);
|
||||
|
||||
@override
|
||||
List<Object> get props => [calendarEventList];
|
||||
}
|
||||
|
||||
class ParseCalendarEventFailure extends FeatureFailure {
|
||||
ParseCalendarEventFailure(dynamic exception) : super(exception: exception);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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: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';
|
||||
|
||||
class ParseCalendarEventInteractor {
|
||||
final CalendarEventRepository _calendarEventRepository;
|
||||
|
||||
ParseCalendarEventInteractor(this._calendarEventRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId, Set<Id> blobIds) async* {
|
||||
try {
|
||||
yield Right(ParseCalendarEventLoading());
|
||||
final calendarEventList = await _calendarEventRepository.parse(accountId, blobIds);
|
||||
yield Right(ParseCalendarEventSuccess(calendarEventList));
|
||||
} catch (e) {
|
||||
yield Left(ParseCalendarEventFailure(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user