fix(cache): retry failed-calendar ranges instead of marking them as cached
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user