mirror of
https://github.com/yattee/yattee.git
synced 2026-07-21 06:42:01 +00:00
Make CloudKit apply path scope-aware and re-upload local-newer merges
CloudKit record names carry a source scope suffix so the same channel or video ID can exist under different sources, but the apply path matched local entities by bare ID: incoming records could merge into an entity from a different scope, and a remote deletion of one scope deleted every local entity with that ID and cascaded scoped deletions for all other scopes back to CloudKit. - Match local entities on the full mapper-derived record name when merging incoming records, materializing records for upload, and applying remote deletions. - Remote deletions now remove only the matching entity and no longer queue CloudKit deletions (no echo, no cross-scope cascade). - Insert dedupe for CloudKit-applied records is scope-aware, so a same-ID record from a different source inserts instead of being silently dropped. Remotely added bookmarks also update the fast-lookup cache immediately. - When conflict resolution during a fetch keeps newer local data, the merge result is queued for upload; previously the server (and other devices) kept the stale version unless the entity was edited again. Strict timestamp comparisons prevent re-upload ping-pong between devices.
This commit is contained in:
@@ -115,6 +115,22 @@ extension DataManager {
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets all notification settings matching a channel ID. The same ID can
|
||||
/// exist under multiple source scopes.
|
||||
func allChannelNotificationSettings(forChannelID channelID: String) -> [ChannelNotificationSettings] {
|
||||
let descriptor = FetchDescriptor<ChannelNotificationSettings>(
|
||||
predicate: #Predicate { $0.channelID == channelID }
|
||||
)
|
||||
return (try? modelContext.fetch(descriptor)) ?? []
|
||||
}
|
||||
|
||||
/// Deletes a single notification settings record without queueing a
|
||||
/// CloudKit deletion. Used by CloudKitSyncEngine when applying remote deletions.
|
||||
func deleteChannelNotificationSettings(_ settings: ChannelNotificationSettings) {
|
||||
modelContext.delete(settings)
|
||||
save()
|
||||
}
|
||||
|
||||
/// Deletes notification settings for a channel.
|
||||
/// - Parameter channelID: The channel ID to delete settings for.
|
||||
func deleteNotificationSettings(for channelID: String) {
|
||||
|
||||
Reference in New Issue
Block a user