TF-2182 Fix no blue bar for calendar events
(cherry picked from commit 7ea91d59e860dbd8f5bd38cefd76ca61bc4cc4e3)
This commit is contained in:
@@ -8,9 +8,14 @@ import 'package:tmail_ui_user/features/offline_mode/model/attachment_hive_cache.
|
||||
extension ListAttachmentsExtension on List<Attachment> {
|
||||
List<AttachmentHiveCache> toHiveCache() => map((attachment) => attachment.toHiveCache()).toList();
|
||||
|
||||
Set<Attachment> get calendarAttachments => where((attachment) => attachment.isCalendarEvent).toSet();
|
||||
Set<Id> get calendarEventBlobIds => subtypeICSBlobIds.isEmpty ? subtypeCalendarBlobIds : subtypeICSBlobIds;
|
||||
|
||||
Set<Id> get calendarEventBlobIds => calendarAttachments
|
||||
Set<Id> get subtypeICSBlobIds => where((attachment) => attachment.type?.subtype == Attachment.eventICSSubtype)
|
||||
.map((attachment) => attachment.blobId)
|
||||
.whereNotNull()
|
||||
.toSet();
|
||||
|
||||
Set<Id> get subtypeCalendarBlobIds => where((attachment) => attachment.type?.subtype == Attachment.eventCalendarSubtype)
|
||||
.map((attachment) => attachment.blobId)
|
||||
.whereNotNull()
|
||||
.toSet();
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/model/event_action.dart';
|
||||
|
||||
abstract class CalendarEventRepository {
|
||||
Future<List<CalendarEvent>> parse(AccountId accountId, Set<Id> blobIds);
|
||||
Future<Map<Id, List<CalendarEvent>>> parse(AccountId accountId, Set<Id> blobIds);
|
||||
|
||||
Future<List<EventAction>> getListEventAction(String emailContents);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ 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/exceptions/calendar_event_exceptions.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';
|
||||
@@ -21,7 +22,7 @@ class ParseCalendarEventInteractor {
|
||||
try {
|
||||
yield Right(ParseCalendarEventLoading());
|
||||
|
||||
final result = await Future.wait(
|
||||
final listResult = await Future.wait(
|
||||
[
|
||||
_calendarEventRepository.parse(accountId, blobIds),
|
||||
_calendarEventRepository.getListEventAction(emailContents),
|
||||
@@ -29,10 +30,24 @@ class ParseCalendarEventInteractor {
|
||||
eagerError: true
|
||||
);
|
||||
|
||||
final calendarEventList = result.first as List<CalendarEvent>;
|
||||
final eventActionList = result.last as List<EventAction>;
|
||||
final listCalendarEvent = List<CalendarEvent>.empty(growable: true);
|
||||
final listEventAction = List<EventAction>.empty(growable: true);
|
||||
|
||||
yield Right(ParseCalendarEventSuccess(calendarEventList, eventActionList));
|
||||
if (listResult[0] is Map<Id, List<CalendarEvent>>) {
|
||||
final mapCalendarEvent = listResult[0] as Map<Id, List<CalendarEvent>>;
|
||||
for (var calendarEvents in mapCalendarEvent.values) {
|
||||
listCalendarEvent.addAll(calendarEvents);
|
||||
}
|
||||
}
|
||||
if (listResult[1] is List<EventAction>) {
|
||||
listEventAction.addAll(listResult[1] as List<EventAction>);
|
||||
}
|
||||
|
||||
if (listCalendarEvent.isNotEmpty) {
|
||||
yield Right(ParseCalendarEventSuccess(listCalendarEvent, listEventAction));
|
||||
} else {
|
||||
yield Left(ParseCalendarEventFailure(NotFoundCalendarEventException()));
|
||||
}
|
||||
} catch (e) {
|
||||
yield Left(ParseCalendarEventFailure(e));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user