Persist per-event Google calendar assignments
This commit is contained in:
+18
-8
@@ -310,6 +310,7 @@ class GoogleCalendarConnection {
|
||||
required this.accountEmail,
|
||||
required this.enabledCalendarIds,
|
||||
this.calendarPersonIds = const {},
|
||||
this.eventPersonIds = const {},
|
||||
required this.lastSync,
|
||||
});
|
||||
|
||||
@@ -317,12 +318,14 @@ class GoogleCalendarConnection {
|
||||
final String accountEmail;
|
||||
final List<String> enabledCalendarIds;
|
||||
final Map<String, String> calendarPersonIds;
|
||||
final Map<String, String> eventPersonIds;
|
||||
final DateTime? lastSync;
|
||||
|
||||
GoogleCalendarConnection copyWith({
|
||||
String? accountEmail,
|
||||
List<String>? enabledCalendarIds,
|
||||
Map<String, String>? calendarPersonIds,
|
||||
Map<String, String>? eventPersonIds,
|
||||
DateTime? lastSync,
|
||||
}) {
|
||||
return GoogleCalendarConnection(
|
||||
@@ -330,6 +333,7 @@ class GoogleCalendarConnection {
|
||||
accountEmail: accountEmail ?? this.accountEmail,
|
||||
enabledCalendarIds: enabledCalendarIds ?? this.enabledCalendarIds,
|
||||
calendarPersonIds: calendarPersonIds ?? this.calendarPersonIds,
|
||||
eventPersonIds: eventPersonIds ?? this.eventPersonIds,
|
||||
lastSync: lastSync ?? this.lastSync,
|
||||
);
|
||||
}
|
||||
@@ -337,6 +341,7 @@ class GoogleCalendarConnection {
|
||||
factory GoogleCalendarConnection.fromJson(Map<String, dynamic> json) {
|
||||
final rawCalendarIds = json['enabledCalendarIds'];
|
||||
final rawCalendarPersonIds = json['calendarPersonIds'];
|
||||
final rawEventPersonIds = json['eventPersonIds'];
|
||||
return GoogleCalendarConnection(
|
||||
id: json['id'] as String? ?? uniqueId(),
|
||||
accountEmail: json['accountEmail'] as String? ?? '',
|
||||
@@ -348,6 +353,11 @@ class GoogleCalendarConnection {
|
||||
(key, value) => MapEntry(key.toString(), value.toString()),
|
||||
)
|
||||
: const {},
|
||||
eventPersonIds: rawEventPersonIds is Map
|
||||
? rawEventPersonIds.map(
|
||||
(key, value) => MapEntry(key.toString(), value.toString()),
|
||||
)
|
||||
: const {},
|
||||
lastSync: DateTime.tryParse(json['lastSync'] as String? ?? ''),
|
||||
);
|
||||
}
|
||||
@@ -357,6 +367,7 @@ class GoogleCalendarConnection {
|
||||
'accountEmail': accountEmail,
|
||||
'enabledCalendarIds': enabledCalendarIds,
|
||||
'calendarPersonIds': calendarPersonIds,
|
||||
'eventPersonIds': eventPersonIds,
|
||||
'lastSync': lastSync?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
@@ -380,16 +391,15 @@ class GoogleCalendarInfo {
|
||||
final backgroundColor = json['backgroundColor'] as String?;
|
||||
return GoogleCalendarInfo(
|
||||
id: json['id'] as String? ?? 'primary',
|
||||
name: json['summaryOverride'] as String? ??
|
||||
name:
|
||||
json['summaryOverride'] as String? ??
|
||||
json['summary'] as String? ??
|
||||
'N\u00e9vtelen Google napt\u00e1r',
|
||||
description: [
|
||||
json['description'] as String?,
|
||||
json['accessRole'] as String?,
|
||||
]
|
||||
.whereType<String>()
|
||||
.where((part) => part.trim().isNotEmpty)
|
||||
.join(' \u00b7 '),
|
||||
description:
|
||||
[json['description'] as String?, json['accessRole'] as String?]
|
||||
.whereType<String>()
|
||||
.where((part) => part.trim().isNotEmpty)
|
||||
.join(' \u00b7 '),
|
||||
color: parseGoogleColor(backgroundColor),
|
||||
primary: json['primary'] == true,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user