Complete rename across all bundle IDs, App Groups, CloudKit containers, StoreKit product IDs, data store filenames, URL schemes, logger subsystems, Swift identifiers, user-facing strings (7 languages), file names, directory names, Xcode project, schemes, assets, and documentation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
60 lines
1.4 KiB
Swift
60 lines
1.4 KiB
Swift
//
|
|
// DataControllerUPDATE.swift
|
|
// Reflect
|
|
//
|
|
// SwiftData UPDATE operations.
|
|
//
|
|
|
|
import SwiftData
|
|
import Foundation
|
|
|
|
extension DataController {
|
|
@discardableResult
|
|
func update(entryDate: Date, withMood mood: Mood) -> Bool {
|
|
guard let entry = getEntry(byDate: entryDate) else {
|
|
return false
|
|
}
|
|
|
|
entry.moodValue = mood.rawValue
|
|
entry.timestamp = Date()
|
|
saveAndRunDataListeners()
|
|
|
|
AnalyticsManager.shared.track(.moodUpdated(mood: mood.rawValue))
|
|
return true
|
|
}
|
|
|
|
// MARK: - Notes
|
|
|
|
@discardableResult
|
|
func updateNotes(forDate date: Date, notes: String?) -> Bool {
|
|
guard let entry = getEntry(byDate: date) else {
|
|
return false
|
|
}
|
|
|
|
entry.notes = notes
|
|
saveAndRunDataListeners()
|
|
|
|
AnalyticsManager.shared.track(.noteUpdated(characterCount: (notes ?? "").count))
|
|
return true
|
|
}
|
|
|
|
// MARK: - Photo
|
|
|
|
@discardableResult
|
|
func updatePhoto(forDate date: Date, photoID: UUID?) -> Bool {
|
|
guard let entry = getEntry(byDate: date) else {
|
|
return false
|
|
}
|
|
|
|
entry.photoID = photoID
|
|
saveAndRunDataListeners()
|
|
|
|
if photoID != nil {
|
|
AnalyticsManager.shared.track(.photoAdded)
|
|
} else {
|
|
AnalyticsManager.shared.track(.photoDeleted)
|
|
}
|
|
return true
|
|
}
|
|
}
|