Sync starred models across machines; add automatic backup scheduling
Favorites now push/pull through a small oai_favorites.json file in the same iCloud Drive folder used by Settings > Backup, reconciled by last-write-wins timestamp on launch and app-become-active. Also adds an Off/Daily/Weekly frequency picker so the full settings backup can run itself (checked at launch and hourly) instead of requiring a manual "Back Up Now" click every time.
This commit is contained in:
@@ -520,10 +520,33 @@ class SettingsService {
|
||||
}
|
||||
}
|
||||
|
||||
/// ISO8601 timestamp of the last local change to favoriteModelIds — used to
|
||||
/// resolve last-write-wins conflicts when syncing favorites across machines.
|
||||
var favoriteModelsUpdatedAt: String {
|
||||
get { cache["favoriteModelsUpdatedAt"] ?? "" }
|
||||
set {
|
||||
cache["favoriteModelsUpdatedAt"] = newValue
|
||||
DatabaseService.shared.setSetting(key: "favoriteModelsUpdatedAt", value: newValue)
|
||||
}
|
||||
}
|
||||
|
||||
func toggleFavoriteModel(_ id: String) {
|
||||
var favs = favoriteModelIds
|
||||
if favs.contains(id) { favs.remove(id) } else { favs.insert(id) }
|
||||
favoriteModelIds = favs
|
||||
favoriteModelsUpdatedAt = ISO8601DateFormatter().string(from: Date())
|
||||
Task { await BackupService.shared.pushFavorites() }
|
||||
}
|
||||
|
||||
// MARK: - Automatic Backup
|
||||
|
||||
/// "manual" (default), "daily", or "weekly"
|
||||
var autoBackupFrequency: String {
|
||||
get { cache["autoBackupFrequency"] ?? "manual" }
|
||||
set {
|
||||
cache["autoBackupFrequency"] = newValue
|
||||
DatabaseService.shared.setSetting(key: "autoBackupFrequency", value: newValue)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Anytype MCP Settings
|
||||
|
||||
Reference in New Issue
Block a user