Enable iCloud sync by default, remove user toggle
- CloudKit sync is now always enabled for all users - Remove useCloudKit setting and toggle from Settings - Remove CloudKitSyncMonitor usage (package can be removed) - Remove container switching logic since sync is always on - Update SharedModelContainer defaults to enable CloudKit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,12 +20,8 @@ final class DataController: ObservableObject {
|
||||
container.mainContext
|
||||
}
|
||||
|
||||
private var useCloudKit: Bool {
|
||||
GroupUserDefaults.groupDefaults.bool(forKey: UserDefaultsStore.Keys.useCloudKit.rawValue)
|
||||
}
|
||||
|
||||
// Listeners for data changes (keeping existing pattern)
|
||||
var switchContainerListeners = [(() -> Void)]()
|
||||
private var editedDataClosure = [() -> Void]()
|
||||
|
||||
// Computed properties for earliest/latest entries
|
||||
@@ -46,19 +42,9 @@ final class DataController: ObservableObject {
|
||||
}
|
||||
|
||||
private init() {
|
||||
let cloudKit = GroupUserDefaults.groupDefaults.bool(forKey: UserDefaultsStore.Keys.useCloudKit.rawValue)
|
||||
container = SharedModelContainer.createWithFallback(useCloudKit: cloudKit)
|
||||
container = SharedModelContainer.createWithFallback(useCloudKit: true)
|
||||
}
|
||||
|
||||
// MARK: - Container Switching (for CloudKit toggle)
|
||||
|
||||
func switchContainer() {
|
||||
save()
|
||||
container = SharedModelContainer.createWithFallback(useCloudKit: useCloudKit)
|
||||
for listener in switchContainerListeners {
|
||||
listener()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Listener Management
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ final class WidgetDataProvider: MoodDataReading {
|
||||
if let existing = _container {
|
||||
return existing
|
||||
}
|
||||
let newContainer = SharedModelContainer.createWithFallback(useCloudKit: false)
|
||||
let newContainer = SharedModelContainer.createWithFallback(useCloudKit: true)
|
||||
_container = newContainer
|
||||
return newContainer
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ enum SharedModelContainer {
|
||||
private static let logger = Logger(subsystem: Bundle.main.bundleIdentifier ?? "com.tt.ifeel", category: "SharedModelContainer")
|
||||
|
||||
/// Creates a ModelContainer with the appropriate configuration for app group sharing
|
||||
/// - Parameter useCloudKit: Whether to enable CloudKit sync
|
||||
/// - Parameter useCloudKit: Whether to enable CloudKit sync (defaults to true)
|
||||
/// - Returns: Configured ModelContainer
|
||||
/// - Throws: SharedModelContainerError if creation fails
|
||||
static func create(useCloudKit: Bool = false) throws -> ModelContainer {
|
||||
static func create(useCloudKit: Bool = true) throws -> ModelContainer {
|
||||
let schema = Schema([MoodEntryModel.self])
|
||||
let storeURL = try Self.storeURL
|
||||
|
||||
@@ -61,9 +61,9 @@ enum SharedModelContainer {
|
||||
}
|
||||
|
||||
/// Creates a ModelContainer, falling back to in-memory storage if shared container fails
|
||||
/// - Parameter useCloudKit: Whether to enable CloudKit sync
|
||||
/// - Parameter useCloudKit: Whether to enable CloudKit sync (defaults to true)
|
||||
/// - Returns: Configured ModelContainer (shared or in-memory fallback)
|
||||
static func createWithFallback(useCloudKit: Bool = false) -> ModelContainer {
|
||||
static func createWithFallback(useCloudKit: Bool = true) -> ModelContainer {
|
||||
do {
|
||||
return try create(useCloudKit: useCloudKit)
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user