Fix 25 audit issues: memory leaks, concurrency, performance, accessibility
Address findings from comprehensive audit across 5 workstreams: - Memory: Token-based DataController listeners (prevent closure leaks), static DateFormatters, ImageCache observer cleanup, MotionManager reference counting, FoundationModels dedup guard - Concurrency: Replace Task.detached with Task in FeelsApp (preserve MainActor isolation), wrap WatchConnectivity handler in MainActor - Performance: Cache sortedGroupedData in DayViewViewModel, cache demo data in MonthView/YearView, remove broken ReduceMotionModifier - Accessibility: VoiceOver support for LockScreen, DemoHeatmapCell labels, MonthCard button labels, InsightsView header traits, Smart Invert protection on neon headers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ final class MoodLogger {
|
||||
|
||||
/// Key for tracking the last date side effects were applied
|
||||
private static let lastSideEffectsDateKey = "lastSideEffectsAppliedDate"
|
||||
private static let sideEffectsDateFormatter = ISO8601DateFormatter()
|
||||
|
||||
private init() {}
|
||||
|
||||
@@ -248,14 +249,14 @@ final class MoodLogger {
|
||||
|
||||
/// Mark that side effects have been applied for a given date
|
||||
private func markSideEffectsApplied(for date: Date) {
|
||||
let dateString = ISO8601DateFormatter().string(from: Calendar.current.startOfDay(for: date))
|
||||
let dateString = Self.sideEffectsDateFormatter.string(from: Calendar.current.startOfDay(for: date))
|
||||
GroupUserDefaults.groupDefaults.set(dateString, forKey: Self.lastSideEffectsDateKey)
|
||||
}
|
||||
|
||||
/// Check if side effects have been applied for a given date
|
||||
private func sideEffectsApplied(for date: Date) -> Bool {
|
||||
guard let lastDateString = GroupUserDefaults.groupDefaults.string(forKey: Self.lastSideEffectsDateKey),
|
||||
let lastDate = ISO8601DateFormatter().date(from: lastDateString) else {
|
||||
let lastDate = Self.sideEffectsDateFormatter.date(from: lastDateString) else {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user