From dd89905b29503561276db1b9131c42a7f66b8ecd Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 26 Jan 2026 17:11:35 -0600 Subject: [PATCH] Signed-off-by: Matt Bruce --- Andromida/Andromida.entitlements | 4 +- Andromida/AndromidaApp.swift | 6 +- Andromida/App/Models/ArcHabit.swift | 10 +- Andromida/App/Models/Ritual.swift | 30 +++--- Andromida/App/Models/RitualArc.swift | 14 +-- .../App/Services/PerformanceLogger.swift | 28 ------ Andromida/App/State/RitualStore.swift | 99 ++++++++++--------- .../App/Views/History/HistoryMonthView.swift | 8 +- Andromida/App/Views/History/HistoryView.swift | 71 +++++++------ .../App/Views/Rituals/RitualDetailView.swift | 11 ++- .../Rituals/Sheets/ArcRenewalSheet.swift | 7 +- Andromida/App/Views/RootView.swift | 7 -- 12 files changed, 133 insertions(+), 162 deletions(-) delete mode 100644 Andromida/App/Services/PerformanceLogger.swift diff --git a/Andromida/Andromida.entitlements b/Andromida/Andromida.entitlements index d1853b1..f807826 100644 --- a/Andromida/Andromida.entitlements +++ b/Andromida/Andromida.entitlements @@ -3,7 +3,9 @@ com.apple.developer.icloud-container-identifiers - + + iCloud.com.mbrucedogs.Andromida + com.apple.developer.icloud-services CloudKit diff --git a/Andromida/AndromidaApp.swift b/Andromida/AndromidaApp.swift index 8378a3b..30d0739 100644 --- a/Andromida/AndromidaApp.swift +++ b/Andromida/AndromidaApp.swift @@ -16,7 +16,11 @@ struct AndromidaApp: App { init() { // Include all models in schema - Ritual, RitualArc, and ArcHabit let schema = Schema([Ritual.self, RitualArc.self, ArcHabit.self]) - let configuration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) + let configuration = ModelConfiguration( + schema: schema, + isStoredInMemoryOnly: false, + cloudKitDatabase: .private("iCloud.com.mbrucedogs.Andromida") + ) let container: ModelContainer do { container = try ModelContainer(for: schema, configurations: [configuration]) diff --git a/Andromida/App/Models/ArcHabit.swift b/Andromida/App/Models/ArcHabit.swift index 9e64b3c..6ae4e0c 100644 --- a/Andromida/App/Models/ArcHabit.swift +++ b/Andromida/App/Models/ArcHabit.swift @@ -6,11 +6,11 @@ import SwiftData /// while preserving historical data. @Model final class ArcHabit { - var id: UUID - var title: String - var symbolName: String - var goal: String - var completedDayIDs: [String] + var id: UUID = UUID() + var title: String = "" + var symbolName: String = "" + var goal: String = "" + var completedDayIDs: [String] = [] @Relationship(inverse: \RitualArc.habits) var arc: RitualArc? diff --git a/Andromida/App/Models/Ritual.swift b/Andromida/App/Models/Ritual.swift index 3ddf5dc..5f5f1ce 100644 --- a/Andromida/App/Models/Ritual.swift +++ b/Andromida/App/Models/Ritual.swift @@ -73,24 +73,24 @@ enum TimeOfDay: String, Codable, CaseIterable, Comparable { /// This allows rituals to be renewed while preserving historical accuracy. @Model final class Ritual { - var id: UUID - var title: String - var theme: String - var notes: String + var id: UUID = UUID() + var title: String = "" + var theme: String = "" + var notes: String = "" // Default duration for new arcs - var defaultDurationDays: Int + var defaultDurationDays: Int = 28 // Scheduling - var timeOfDay: TimeOfDay + var timeOfDay: TimeOfDay = .anytime // Organization - var iconName: String - var category: String + var iconName: String = "sparkles" + var category: String = "" // Arcs - each arc represents a time-bound period with its own habits @Relationship(deleteRule: .cascade) - var arcs: [RitualArc] + var arcs: [RitualArc]? = [] init( id: UUID = UUID(), @@ -118,7 +118,7 @@ final class Ritual { /// The currently active arc, if any. var currentArc: RitualArc? { - arcs.first { $0.isActive } + arcs?.first { $0.isActive } } /// Whether this ritual has an active arc in progress. @@ -128,7 +128,7 @@ final class Ritual { /// All arcs sorted by start date (newest first). var sortedArcs: [RitualArc] { - arcs.sorted { $0.startDate > $1.startDate } + (arcs ?? []).sorted { $0.startDate > $1.startDate } } /// The most recent arc (active or completed). @@ -138,12 +138,12 @@ final class Ritual { /// Total number of completed arcs. var completedArcCount: Int { - arcs.filter { !$0.isActive }.count + (arcs ?? []).filter { !$0.isActive }.count } /// The end date of the most recently completed arc, if any. var lastCompletedDate: Date? { - arcs.filter { !$0.isActive } + (arcs ?? []).filter { !$0.isActive } .sorted { $0.endDate > $1.endDate } .first?.endDate } @@ -174,12 +174,12 @@ final class Ritual { /// Returns the arc that was active on a specific date, if any. func arc(for date: Date) -> RitualArc? { - arcs.first { $0.contains(date: date) } + (arcs ?? []).first { $0.contains(date: date) } } /// Returns all arcs that overlap with a date range. func arcs(in range: ClosedRange) -> [RitualArc] { - arcs.filter { arc in + (arcs ?? []).filter { arc in // Arc overlaps if its range intersects with the query range arc.endDate >= range.lowerBound && arc.startDate <= range.upperBound } diff --git a/Andromida/App/Models/RitualArc.swift b/Andromida/App/Models/RitualArc.swift index 09a5416..d4e61b9 100644 --- a/Andromida/App/Models/RitualArc.swift +++ b/Andromida/App/Models/RitualArc.swift @@ -6,14 +6,14 @@ import SwiftData /// the old arc's data remains frozen for historical accuracy. @Model final class RitualArc { - var id: UUID - var startDate: Date - var endDate: Date - var arcNumber: Int - var isActive: Bool + var id: UUID = UUID() + var startDate: Date = Date() + var endDate: Date = Date() + var arcNumber: Int = 1 + var isActive: Bool = true @Relationship(deleteRule: .cascade) - var habits: [ArcHabit] + var habits: [ArcHabit]? = [] @Relationship(inverse: \Ritual.arcs) var ritual: Ritual? @@ -88,7 +88,7 @@ final class RitualArc { let newStartDate = calendar.date(byAdding: .day, value: 1, to: endDate) ?? Date() let newDuration = durationDays ?? self.durationDays - let copiedHabits = habits.map { $0.copyForNewArc() } + let copiedHabits = (habits ?? []).map { $0.copyForNewArc() } return RitualArc( startDate: newStartDate, diff --git a/Andromida/App/Services/PerformanceLogger.swift b/Andromida/App/Services/PerformanceLogger.swift deleted file mode 100644 index 579414e..0000000 --- a/Andromida/App/Services/PerformanceLogger.swift +++ /dev/null @@ -1,28 +0,0 @@ -import Foundation -import os - -enum PerformanceLogger { - private static let logger = Logger( - subsystem: Bundle.main.bundleIdentifier ?? "Andromida", - category: "Performance" - ) - - static func measure(_ name: String, _ block: () -> T) -> T { - #if DEBUG - let start = CFAbsoluteTimeGetCurrent() - let result = block() - let duration = CFAbsoluteTimeGetCurrent() - start - logger.info("\(name, privacy: .public) took \(duration, format: .fixed(precision: 3))s") - return result - #else - return block() - #endif - } - - static func logDuration(_ name: String, from start: CFAbsoluteTime) { - #if DEBUG - let duration = CFAbsoluteTimeGetCurrent() - start - logger.info("\(name, privacy: .public) took \(duration, format: .fixed(precision: 3))s") - #endif - } -} diff --git a/Andromida/App/State/RitualStore.swift b/Andromida/App/State/RitualStore.swift index 770668e..316944a 100644 --- a/Andromida/App/State/RitualStore.swift +++ b/Andromida/App/State/RitualStore.swift @@ -72,10 +72,8 @@ final class RitualStore: RitualStoreProviding { /// Refreshes rituals and derived state for current date/time. func refresh() { - PerformanceLogger.measure("RitualStore.refresh") { - reloadRituals() - checkForCompletedArcs() - } + reloadRituals() + checkForCompletedArcs() } func ritualProgress(for ritual: Ritual) -> Double { @@ -174,12 +172,12 @@ final class RitualStore: RitualStoreProviding { /// Returns all arcs that were active on a specific date. func arcsActive(on date: Date) -> [RitualArc] { - rituals.flatMap { $0.arcs }.filter { $0.contains(date: date) } + rituals.flatMap { $0.arcs ?? [] }.filter { $0.contains(date: date) } } /// Returns habits from all arcs that were active on a specific date. func habitsActive(on date: Date) -> [ArcHabit] { - arcsActive(on: date).flatMap { $0.habits } + arcsActive(on: date).flatMap { $0.habits ?? [] } } /// Checks if a ritual's current arc has completed (past end date). @@ -217,7 +215,7 @@ final class RitualStore: RitualStoreProviding { let newHabits: [ArcHabit] if copyHabits, let previousArc = ritual.latestArc { - newHabits = previousArc.habits.map { $0.copyForNewArc() } + newHabits = (previousArc.habits ?? []).map { $0.copyForNewArc() } } else { newHabits = [] } @@ -230,7 +228,9 @@ final class RitualStore: RitualStoreProviding { habits: newHabits ) - ritual.arcs.append(newArc) + var arcs = ritual.arcs ?? [] + arcs.append(newArc) + ritual.arcs = arcs saveContext() } @@ -360,7 +360,10 @@ final class RitualStore: RitualStoreProviding { var breakdown: [BreakdownItem] = [] // Total check-ins - let totalCheckIns = rituals.flatMap { $0.arcs }.flatMap { $0.habits }.reduce(0) { $0 + $1.completedDayIDs.count } + let totalCheckIns = rituals + .flatMap { $0.arcs ?? [] } + .flatMap { $0.habits ?? [] } + .reduce(0) { $0 + $1.completedDayIDs.count } breakdown.append(BreakdownItem( label: String(localized: "Total check-ins"), value: "\(totalCheckIns)" @@ -392,7 +395,7 @@ final class RitualStore: RitualStoreProviding { // Per-ritual breakdown for ritual in rituals { - let ritualDays = Set(ritual.arcs.flatMap { $0.habits }.flatMap { $0.completedDayIDs }).count + let ritualDays = Set((ritual.arcs ?? []).flatMap { $0.habits ?? [] }.flatMap { $0.completedDayIDs }).count breakdown.append(BreakdownItem( label: ritual.title, value: String(localized: "\(ritualDays) days") @@ -409,9 +412,7 @@ final class RitualStore: RitualStoreProviding { func refreshInsightCardsIfNeeded() { guard insightCardsNeedRefresh else { return } - cachedInsightCards = PerformanceLogger.measure("RitualStore.insightCards") { - computeInsightCards() - } + cachedInsightCards = computeInsightCards() insightCardsNeedRefresh = false } @@ -630,14 +631,18 @@ final class RitualStore: RitualStoreProviding { func addHabit(to ritual: Ritual, title: String, symbolName: String) { guard let arc = ritual.currentArc else { return } let habit = ArcHabit(title: title, symbolName: symbolName) - arc.habits.append(habit) + var habits = arc.habits ?? [] + habits.append(habit) + arc.habits = habits saveContext() } /// Removes a habit from the current arc of a ritual func removeHabit(_ habit: ArcHabit, from ritual: Ritual) { guard let arc = ritual.currentArc else { return } - arc.habits.removeAll { $0.id == habit.id } + var habits = arc.habits ?? [] + habits.removeAll { $0.id == habit.id } + arc.habits = habits modelContext.delete(habit) saveContext() } @@ -649,15 +654,13 @@ final class RitualStore: RitualStoreProviding { } private func reloadRituals() { - PerformanceLogger.measure("RitualStore.reloadRituals") { - do { - rituals = try modelContext.fetch(FetchDescriptor()) - updateDerivedData() - invalidateAnalyticsCache() - scheduleReminderUpdate() - } catch { - lastErrorMessage = error.localizedDescription - } + do { + rituals = try modelContext.fetch(FetchDescriptor()) + updateDerivedData() + invalidateAnalyticsCache() + scheduleReminderUpdate() + } catch { + lastErrorMessage = error.localizedDescription } } @@ -692,23 +695,21 @@ final class RitualStore: RitualStoreProviding { } private func computeDatesWithActivity() -> Set { - PerformanceLogger.measure("RitualStore.computeDatesWithActivity") { - var dates: Set = [] + var dates: Set = [] - for ritual in rituals { - for arc in ritual.arcs { - for habit in arc.habits { - for dayID in habit.completedDayIDs { - if let date = dayFormatter.date(from: dayID) { - dates.insert(calendar.startOfDay(for: date)) - } + for ritual in rituals { + for arc in ritual.arcs ?? [] { + for habit in arc.habits ?? [] { + for dayID in habit.completedDayIDs { + if let date = dayFormatter.date(from: dayID) { + dates.insert(calendar.startOfDay(for: date)) } } } } - - return dates } + + return dates } private func computePerfectDays(from activeDates: Set) -> Set { @@ -756,7 +757,7 @@ final class RitualStore: RitualStoreProviding { if let ritual = ritual { // Get habits from the arc that was active on this date if let arc = ritual.arc(for: date) { - habits = arc.habits + habits = arc.habits ?? [] } else { return 0 } @@ -792,7 +793,7 @@ final class RitualStore: RitualStoreProviding { if let ritual = ritual { // Get habits from the arc that was active on this date if let arc = ritual.arc(for: date) { - for habit in arc.habits { + for habit in arc.habits ?? [] { completions.append(HabitCompletion( habit: habit, ritualTitle: ritual.title, @@ -804,7 +805,7 @@ final class RitualStore: RitualStoreProviding { // Get all habits from all arcs that were active on this date for r in rituals { if let arc = r.arc(for: date) { - for habit in arc.habits { + for habit in arc.habits ?? [] { completions.append(HabitCompletion( habit: habit, ritualTitle: r.title, @@ -885,14 +886,16 @@ final class RitualStore: RitualStoreProviding { /// Returns the current streak for a specific ritual's current arc. func streakForRitual(_ ritual: Ritual) -> Int { - guard let arc = ritual.currentArc, !arc.habits.isEmpty else { return 0 } + guard let arc = ritual.currentArc else { return 0 } + let habits = arc.habits ?? [] + guard !habits.isEmpty else { return 0 } var streak = 0 var checkDate = calendar.startOfDay(for: Date()) while arc.contains(date: checkDate) { let dayID = dayIdentifier(for: checkDate) - let allCompleted = arc.habits.allSatisfy { $0.completedDayIDs.contains(dayID) } + let allCompleted = habits.allSatisfy { $0.completedDayIDs.contains(dayID) } if allCompleted { streak += 1 @@ -993,7 +996,7 @@ final class RitualStore: RitualStoreProviding { // Update each ritual's arcs to cover a longer period for ritual in rituals { // For each arc (active or not), extend it to cover the demo period - for arc in ritual.arcs { + for arc in ritual.arcs ?? [] { // Set the arc to start 6 months ago and be active arc.startDate = sixMonthsAgo arc.endDate = calendar.date(byAdding: .day, value: 180 + 28 - 1, to: sixMonthsAgo) ?? today @@ -1001,7 +1004,7 @@ final class RitualStore: RitualStoreProviding { } // If no arcs exist, create one - if ritual.arcs.isEmpty { + if (ritual.arcs ?? []).isEmpty { let demoHabits = [ ArcHabit(title: "Demo Habit 1", symbolName: "star.fill"), ArcHabit(title: "Demo Habit 2", symbolName: "heart.fill") @@ -1013,7 +1016,9 @@ final class RitualStore: RitualStoreProviding { isActive: true, habits: demoHabits ) - ritual.arcs.append(demoArc) + var arcs = ritual.arcs ?? [] + arcs.append(demoArc) + ritual.arcs = arcs } } @@ -1024,11 +1029,11 @@ final class RitualStore: RitualStoreProviding { let dayID = dayIdentifier(for: currentDate) for ritual in rituals { - for arc in ritual.arcs { + for arc in ritual.arcs ?? [] { // Only generate completions if the arc covers this date guard arc.contains(date: currentDate) else { continue } - for habit in arc.habits { + for habit in arc.habits ?? [] { // Random completion with ~70% average success rate let threshold = Double.random(in: 0.5...0.9) let shouldComplete = Double.random(in: 0...1) < threshold @@ -1049,8 +1054,8 @@ final class RitualStore: RitualStoreProviding { /// Clears all completion data (for testing). func clearAllCompletions() { for ritual in rituals { - for arc in ritual.arcs { - for habit in arc.habits { + for arc in ritual.arcs ?? [] { + for habit in arc.habits ?? [] { habit.completedDayIDs.removeAll() } } diff --git a/Andromida/App/Views/History/HistoryMonthView.swift b/Andromida/App/Views/History/HistoryMonthView.swift index 9879953..de364a8 100644 --- a/Andromida/App/Views/History/HistoryMonthView.swift +++ b/Andromida/App/Views/History/HistoryMonthView.swift @@ -88,11 +88,9 @@ struct HistoryMonthView: View { private var dayGrid: some View { let columns = Array(repeating: GridItem(.flexible(), spacing: Design.Spacing.xSmall), count: 7) let dates = daysInMonth - let progressValues = PerformanceLogger.measure("HistoryMonthView.progressValues.\(monthTitle)") { - dates.map { date -> Double? in - guard let date else { return nil } - return date > today ? 0 : completionRate(date, selectedRitual) - } + let progressValues = dates.map { date -> Double? in + guard let date else { return nil } + return date > today ? 0 : completionRate(date, selectedRitual) } return LazyVGrid(columns: columns, spacing: Design.Spacing.xSmall) { diff --git a/Andromida/App/Views/History/HistoryView.swift b/Andromida/App/Views/History/HistoryView.swift index 3223c6b..e2b7f61 100644 --- a/Andromida/App/Views/History/HistoryView.swift +++ b/Andromida/App/Views/History/HistoryView.swift @@ -32,29 +32,27 @@ struct HistoryView: View { /// - Expanded: Up to 12 months of history /// Months are ordered oldest first, newest last (chronological order) private var months: [Date] { - PerformanceLogger.measure("HistoryView.months") { - let today = Date() - let currentMonth = calendar.date(from: calendar.dateComponents([.year, .month], from: today)) ?? today - - // Determine how far back to go - let totalAvailableMonths = totalMonthsAvailable(from: currentMonth) - let effectiveMonthsToShow = min(monthsToShow, totalAvailableMonths) - let monthsBack = max(0, effectiveMonthsToShow - 1) - guard let startMonth = calendar.date(byAdding: .month, value: -monthsBack, to: currentMonth) else { - return [currentMonth] - } - - // Build list of months in chronological order (oldest first) - var result: [Date] = [] - var current = startMonth - - while current <= currentMonth { - result.append(current) - current = calendar.date(byAdding: .month, value: 1, to: current) ?? current - } - - return result + let today = Date() + let currentMonth = calendar.date(from: calendar.dateComponents([.year, .month], from: today)) ?? today + + // Determine how far back to go + let totalAvailableMonths = totalMonthsAvailable(from: currentMonth) + let effectiveMonthsToShow = min(monthsToShow, totalAvailableMonths) + let monthsBack = max(0, effectiveMonthsToShow - 1) + guard let startMonth = calendar.date(byAdding: .month, value: -monthsBack, to: currentMonth) else { + return [currentMonth] } + + // Build list of months in chronological order (oldest first) + var result: [Date] = [] + var current = startMonth + + while current <= currentMonth { + result.append(current) + current = calendar.date(byAdding: .month, value: 1, to: current) ?? current + } + + return result } /// Check if there's more history available beyond what's shown @@ -200,26 +198,23 @@ struct HistoryView: View { await Task.yield() let snapshotMonths = months let selected = selectedRitual - let cache = PerformanceLogger.measure("HistoryView.progressCache") { - var result: [Date: Double] = [:] - let today = calendar.startOfDay(for: Date()) + var result: [Date: Double] = [:] + let today = calendar.startOfDay(for: Date()) - for month in snapshotMonths { - guard let firstOfMonth = calendar.date(from: calendar.dateComponents([.year, .month], from: month)), - let range = calendar.range(of: .day, in: .month, for: firstOfMonth) else { - continue - } - - for day in range { - guard let date = calendar.date(byAdding: .day, value: day - 1, to: firstOfMonth) else { continue } - let normalizedDate = calendar.startOfDay(for: date) - guard normalizedDate <= today else { continue } - result[normalizedDate] = store.completionRate(for: normalizedDate, ritual: selected) - } + for month in snapshotMonths { + guard let firstOfMonth = calendar.date(from: calendar.dateComponents([.year, .month], from: month)), + let range = calendar.range(of: .day, in: .month, for: firstOfMonth) else { + continue } - return result + for day in range { + guard let date = calendar.date(byAdding: .day, value: day - 1, to: firstOfMonth) else { continue } + let normalizedDate = calendar.startOfDay(for: date) + guard normalizedDate <= today else { continue } + result[normalizedDate] = store.completionRate(for: normalizedDate, ritual: selected) + } } + let cache = result cachedProgressByDate = cache } } diff --git a/Andromida/App/Views/Rituals/RitualDetailView.swift b/Andromida/App/Views/Rituals/RitualDetailView.swift index 3f27211..3fc69ef 100644 --- a/Andromida/App/Views/Rituals/RitualDetailView.swift +++ b/Andromida/App/Views/Rituals/RitualDetailView.swift @@ -36,11 +36,11 @@ struct RitualDetailView: View { } private var hasMultipleArcs: Bool { - ritual.arcs.count > 1 + (ritual.arcs ?? []).count > 1 } private var completedArcs: [RitualArc] { - ritual.arcs.filter { !$0.isActive }.sorted { $0.startDate > $1.startDate } + (ritual.arcs ?? []).filter { !$0.isActive }.sorted { $0.startDate > $1.startDate } } var body: some View { @@ -353,7 +353,7 @@ struct RitualDetailView: View { VStack(alignment: .leading, spacing: Design.Spacing.medium) { SectionHeaderView( title: String(localized: "Arc History"), - subtitle: ritual.arcs.isEmpty ? nil : String(localized: "\(ritual.arcs.count) total") + subtitle: (ritual.arcs ?? []).isEmpty ? nil : String(localized: "\((ritual.arcs ?? []).count) total") ) if completedArcs.isEmpty { @@ -374,8 +374,9 @@ struct RitualDetailView: View { let dateFormatter = DateFormatter() dateFormatter.dateStyle = .medium - let totalCheckIns = arc.habits.reduce(0) { $0 + $1.completedDayIDs.count } - let possibleCheckIns = arc.habits.count * arc.durationDays + let habits = arc.habits ?? [] + let totalCheckIns = habits.reduce(0) { $0 + $1.completedDayIDs.count } + let possibleCheckIns = habits.count * arc.durationDays let completionRate = possibleCheckIns > 0 ? Int(Double(totalCheckIns) / Double(possibleCheckIns) * 100) : 0 return HStack { diff --git a/Andromida/App/Views/Rituals/Sheets/ArcRenewalSheet.swift b/Andromida/App/Views/Rituals/Sheets/ArcRenewalSheet.swift index ed8e10f..85d73e8 100644 --- a/Andromida/App/Views/Rituals/Sheets/ArcRenewalSheet.swift +++ b/Andromida/App/Views/Rituals/Sheets/ArcRenewalSheet.swift @@ -24,8 +24,9 @@ struct ArcRenewalSheet: View { private var arcSummary: String { guard let arc = completedArc else { return "" } - let totalHabits = arc.habits.count - let totalCheckIns = arc.habits.reduce(0) { $0 + $1.completedDayIDs.count } + let habits = arc.habits ?? [] + let totalHabits = habits.count + let totalCheckIns = habits.reduce(0) { $0 + $1.completedDayIDs.count } let possibleCheckIns = totalHabits * arc.durationDays let rate = possibleCheckIns > 0 ? Int(Double(totalCheckIns) / Double(possibleCheckIns) * 100) : 0 return String(localized: "\(rate)% completion over \(arc.durationDays) days") @@ -94,7 +95,7 @@ struct ArcRenewalSheet: View { .font(.subheadline) if let arc = completedArc { - let habitCount = arc.habits.count + let habitCount = (arc.habits ?? []).count HStack { Image(systemName: "checkmark.circle.fill") .foregroundStyle(AppAccent.primary) diff --git a/Andromida/App/Views/RootView.swift b/Andromida/App/Views/RootView.swift index 742bb23..c921583 100644 --- a/Andromida/App/Views/RootView.swift +++ b/Andromida/App/Views/RootView.swift @@ -1,6 +1,5 @@ import SwiftUI import Bedrock -import Foundation struct RootView: View { @Bindable var store: RitualStore @@ -85,9 +84,7 @@ struct RootView: View { Task { // Let tab selection UI update before refreshing data. await Task.yield() - let refreshStart = CFAbsoluteTimeGetCurrent() store.refresh() - PerformanceLogger.logDuration("RootView.refreshCurrentTab.store.refresh", from: refreshStart) analyticsPrewarmTask?.cancel() if selectedTab != .insights { analyticsPrewarmTask = Task { @MainActor in @@ -98,12 +95,8 @@ struct RootView: View { } } if selectedTab == .settings { - let settingsStart = CFAbsoluteTimeGetCurrent() settingsStore.refresh() - PerformanceLogger.logDuration("RootView.refreshCurrentTab.settings.refresh", from: settingsStart) - let reminderStart = CFAbsoluteTimeGetCurrent() await store.reminderScheduler.refreshStatus() - PerformanceLogger.logDuration("RootView.refreshCurrentTab.reminderStatus", from: reminderStart) } } }