Release 1.0.0 baseline
This commit is contained in:
@@ -28,8 +28,10 @@ final class CalendarService {
|
||||
weekStartDate: Date,
|
||||
settings: AppSettings
|
||||
) -> String? {
|
||||
guard let calendarId = settings.calendarId,
|
||||
let calendar = eventStore.calendar(withIdentifier: calendarId) else { return nil }
|
||||
guard let calendar = resolvedCalendar(for: settings) else {
|
||||
print("Calendar sync skipped: no writable calendar available")
|
||||
return nil
|
||||
}
|
||||
|
||||
let event = EKEvent(eventStore: eventStore)
|
||||
|
||||
@@ -81,4 +83,17 @@ final class CalendarService {
|
||||
try? eventStore.save(event, span: .thisEvent)
|
||||
}
|
||||
}
|
||||
|
||||
private func resolvedCalendar(for settings: AppSettings) -> EKCalendar? {
|
||||
if let calendarId = settings.calendarId,
|
||||
let calendar = eventStore.calendar(withIdentifier: calendarId) {
|
||||
return calendar
|
||||
}
|
||||
|
||||
if let defaultCalendar = eventStore.defaultCalendarForNewEvents {
|
||||
return defaultCalendar
|
||||
}
|
||||
|
||||
return eventStore.calendars(for: .event).first
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user