From fb22aeb090a2f7963564028e8af804739a182686 Mon Sep 17 00:00:00 2001 From: Scarriffle Date: Fri, 3 Jul 2026 20:55:57 +0200 Subject: [PATCH] fix(cache): retry failed-calendar ranges instead of marking them as cached MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mergeIntoCache() previously extended cachedStart/End even when sync errors occurred — so isCached() returned true on the next call and the failed calendar was silently left empty (especially bad on first launch or after forceReload when there's nothing to preserve). Now the cached range is only extended on a fully clean fetch. When keepKeysInRange is non-empty (sync errors present), we leave cachedStart/End unchanged, forcing isCached() to return false and triggering an automatic retry on the next loadEvents call. Co-Authored-By: Claude Sonnet 4.6 --- Calendarr iOS/Models/CalendarStore.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Calendarr iOS/Models/CalendarStore.swift b/Calendarr iOS/Models/CalendarStore.swift index 6edde83..26a68d0 100644 --- a/Calendarr iOS/Models/CalendarStore.swift +++ b/Calendarr iOS/Models/CalendarStore.swift @@ -456,7 +456,13 @@ class CalendarStore { } allCachedEvents = retained + newEvents - // Extend cached range + // Only extend the cached range when the fetch was completely clean. + // When some calendars had sync errors (keepKeysInRange non-empty), leave + // cachedStart/End unchanged: this keeps isCached() returning false for + // the next loadEvents call so the failed calendars are retried + // automatically — rather than being silently treated as "done" with + // empty data (especially important on first launch or after forceReload). + guard keepKeysInRange.isEmpty else { return } if let cs = cachedStart, let ce = cachedEnd { cachedStart = min(cs, rangeStart) cachedEnd = max(ce, rangeEnd)