Fix 7 data mutation layer risks identified in audit
- save()/saveAndRunDataListeners() now return @discardableResult Bool; listeners only fire on successful save - MoodLogger.updateMood() now recalculates streak, updates Live Activity, and notifies watch (was missing these side effects) - CSV import uses new addBatch()/importMoods() for O(1) side effects instead of O(n) per-row widget reloads and streak calcs - Foreground task ordering: fillInMissingDates() now runs before removeDuplicates() so backfill-created duplicates are caught same cycle - WidgetMoodSaver deletes ALL entries for date (was fetchLimit=1, leaving CloudKit sync duplicates behind) - cleanupPhotoIfNeeded logs warning on failed photo deletion instead of silently orphaning files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -70,10 +70,12 @@ protocol MoodDataDeleting {
|
||||
@MainActor
|
||||
protocol MoodDataPersisting {
|
||||
/// Save pending changes
|
||||
func save()
|
||||
@discardableResult
|
||||
func save() -> Bool
|
||||
|
||||
/// Save and notify listeners
|
||||
func saveAndRunDataListeners()
|
||||
@discardableResult
|
||||
func saveAndRunDataListeners() -> Bool
|
||||
|
||||
/// Add a listener for data changes
|
||||
func addNewDataListener(closure: @escaping (() -> Void))
|
||||
|
||||
Reference in New Issue
Block a user