Make the per-calendar reminder toggle visible and keep what it sets
Three faults made the existing toggle unreliable on iOS.
Opening the filter or the drawer rebuilt the muted set from the five
server-backed sources and replaced the whole thing, so every device-calendar
mute was silently dropped — along with the mute of any calendar the server did
not happen to return. Only the server-backed part is replaced now.
Device-calendar events carry no reminders of their own, so the global default
applied and Calendarr notified on top of the system Calendar app. They stay
silent unless the event brings its own reminder; the per-calendar toggle can
still switch them on, which it could not before because of the fault above.
The toggle itself lived only behind a long press, with nothing to suggest it
existed until after it had been used — the bell.slash icon appeared only once
muted. It is a visible button in the row now, the way Android already does it,
and the duplicate context-menu entry is gone.
Local calendars use the new reminders endpoint, so a recipient's mute reaches
the server instead of dying in a 404 that `try?` swallowed.
Also adds the EventKit import that c811486 needed in five files: that commit
left beta unable to build for either iOS or Mac Catalyst.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
25f015a15b
commit
96cbbb0dc5
BIN
Binary file not shown.
@@ -1,6 +1,8 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import CalendarrCore
|
||||
// loadWritableCalendars reads EKCalendar.title/.calendarIdentifier directly.
|
||||
import EventKit
|
||||
|
||||
extension Notification.Name {
|
||||
/// Posted whenever the persistent "banished calendars" set is mutated from
|
||||
|
||||
@@ -532,7 +532,7 @@ class CalendarrAPI {
|
||||
case "caldav": path = "/api/caldav/calendars/\(calendarId)"
|
||||
case "google": path = "/api/google/calendars/\(calendarId)"
|
||||
case "homeassistant": path = "/api/homeassistant/calendars/\(calendarId)"
|
||||
case "local": path = "/api/local/calendars/\(calendarId)"
|
||||
case "local": path = "/api/local/calendars/\(calendarId)/reminders"
|
||||
case "ical": path = "/api/ical/subscriptions/\(calendarId)"
|
||||
default: return
|
||||
}
|
||||
|
||||
@@ -35,8 +35,13 @@ enum NotificationScheduler {
|
||||
let key = CalendarStore.calendarKey(source: ev.source, calendarId: ev.calendarId)
|
||||
if disabledCalendarKeys.contains(key) { continue }
|
||||
}
|
||||
// Device calendars are already served by the system Calendar
|
||||
// app, so applying our default here notifies twice for one
|
||||
// event. They stay silent unless the event carries its own
|
||||
// reminder; the per-calendar toggle can still switch them on.
|
||||
let allowsDefault = defaultMin >= 0 && ev.source != "device"
|
||||
let offsets = ev.reminders.isEmpty
|
||||
? (defaultMin >= 0 ? [defaultMin] : [])
|
||||
? (allowsDefault ? [defaultMin] : [])
|
||||
: ev.reminders
|
||||
for m in offsets {
|
||||
let fire = ev.startDate.addingTimeInterval(-Double(m) * 60)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
import EventKit
|
||||
|
||||
struct AccountsView: View {
|
||||
let api: CalendarrAPI
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import SwiftUI
|
||||
import EventKit
|
||||
|
||||
/// `.sheet(item:)` needs Identifiable and URL is not. A retroactive conformance
|
||||
/// on a stdlib type would be visible module-wide, so wrap it instead.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
import EventKit
|
||||
|
||||
struct EventEditorSheet: View {
|
||||
let api: CalendarrAPI
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import SwiftUI
|
||||
import EventKit
|
||||
|
||||
/// A single calendar row in the flat, reorderable list.
|
||||
private struct CalRow: Identifiable {
|
||||
@@ -87,39 +88,44 @@ struct CalendarFilterContent: View {
|
||||
@ViewBuilder
|
||||
private func row(_ cal: CalRow) -> some View {
|
||||
let isVisible = !hidden.contains(cal.id)
|
||||
Button {
|
||||
if isVisible { hidden.insert(cal.id) } else { hidden.remove(cal.id) }
|
||||
store.setCalendarHidden(cal.id, hidden: isVisible)
|
||||
} label: {
|
||||
HStack(spacing: 12) {
|
||||
Circle()
|
||||
.fill(Color(hex: cal.colorHex))
|
||||
.frame(width: 14, height: 14)
|
||||
.opacity(isVisible ? 1.0 : 0.35)
|
||||
Text(cal.name)
|
||||
.foregroundStyle(isVisible ? .primary : .secondary)
|
||||
.strikethrough(!isVisible, color: .secondary)
|
||||
if cal.readOnly {
|
||||
Image(systemName: "lock.fill").font(.caption2).foregroundStyle(.secondary)
|
||||
let muted = reminderDisabled.contains(cal.id)
|
||||
HStack(spacing: 8) {
|
||||
Button {
|
||||
if isVisible { hidden.insert(cal.id) } else { hidden.remove(cal.id) }
|
||||
store.setCalendarHidden(cal.id, hidden: isVisible)
|
||||
} label: {
|
||||
HStack(spacing: 12) {
|
||||
Circle()
|
||||
.fill(Color(hex: cal.colorHex))
|
||||
.frame(width: 14, height: 14)
|
||||
.opacity(isVisible ? 1.0 : 0.35)
|
||||
Text(cal.name)
|
||||
.foregroundStyle(isVisible ? .primary : .secondary)
|
||||
.strikethrough(!isVisible, color: .secondary)
|
||||
if cal.readOnly {
|
||||
Image(systemName: "lock.fill").font(.caption2).foregroundStyle(.secondary)
|
||||
}
|
||||
Spacer()
|
||||
Image(systemName: isVisible ? "eye" : "eye.slash")
|
||||
.foregroundStyle(isVisible ? Color.accentColor : .secondary)
|
||||
}
|
||||
Spacer()
|
||||
if reminderDisabled.contains(cal.id) {
|
||||
Image(systemName: "bell.slash").font(.caption).foregroundStyle(.secondary)
|
||||
}
|
||||
Image(systemName: isVisible ? "eye" : "eye.slash")
|
||||
.foregroundStyle(isVisible ? Color.accentColor : .secondary)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.contextMenu {
|
||||
.buttonStyle(.plain)
|
||||
|
||||
// A visible control, the way Android already does it. The mute used
|
||||
// to live only behind a long press, with no hint it existed until
|
||||
// after it had been switched on.
|
||||
Button {
|
||||
toggleReminders(forKey: cal.id)
|
||||
} label: {
|
||||
let disabled = reminderDisabled.contains(cal.id)
|
||||
Label(L10n.t(disabled ? "filter.reminders_on" : "filter.reminders_off", appLang),
|
||||
systemImage: disabled ? "bell" : "bell.slash")
|
||||
Image(systemName: muted ? "bell.slash" : "bell")
|
||||
.foregroundStyle(muted ? .secondary : Color.accentColor)
|
||||
}
|
||||
.buttonStyle(.borderless)
|
||||
.accessibilityLabel(L10n.t(muted ? "filter.reminders_on" : "filter.reminders_off", appLang))
|
||||
}
|
||||
.contextMenu {
|
||||
Button(role: .destructive) {
|
||||
hidden.remove(cal.id)
|
||||
banished.insert(cal.id)
|
||||
@@ -226,8 +232,16 @@ struct CalendarFilterContent: View {
|
||||
for sub in icalSubs { applyReminders("ical", sub.id, sub.remindersEnabled ?? true) }
|
||||
for acc in googleAccounts { for cal in acc.calendars ?? [] { applyReminders("google", cal.id, cal.remindersEnabled ?? true) } }
|
||||
for acc in haAccounts { for cal in acc.calendars ?? [] { applyReminders("homeassistant", cal.id, cal.remindersEnabled) } }
|
||||
store.setReminderDisabledKeys(rd)
|
||||
reminderDisabled = rd
|
||||
// Only server-backed sources are reconciled here. Replacing the whole
|
||||
// set would drop every device-calendar mute — and the mute of any
|
||||
// calendar the server happened not to return on this call.
|
||||
let serverSources: Set<String> = ["local", "caldav", "ical", "google", "homeassistant"]
|
||||
let keptLocally = store.reminderDisabledKeys.filter { key in
|
||||
!serverSources.contains(key.split(separator: ":").first.map(String.init) ?? "")
|
||||
}
|
||||
let merged = rd.union(keptLocally)
|
||||
store.setReminderDisabledKeys(merged)
|
||||
reminderDisabled = merged
|
||||
|
||||
// Build the flat row list (banished excluded), then sort by stored order.
|
||||
var combined: [CalRow] = []
|
||||
|
||||
Reference in New Issue
Block a user