From e453dc5db9dddf7496f7090b1f467f3403124c72 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 23 Apr 2024 11:50:28 -0700 Subject: [PATCH] Recreate MenuBarTimelineView task after view re-init --- Aware/macOS/MenuBarTimelineView.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Aware/macOS/MenuBarTimelineView.swift b/Aware/macOS/MenuBarTimelineView.swift index dc35937..b02cbef 100644 --- a/Aware/macOS/MenuBarTimelineView.swift +++ b/Aware/macOS/MenuBarTimelineView.swift @@ -17,6 +17,8 @@ struct MenuBarTimelineView: View let schedule: Schedule let content: (MenuBarTimelineViewDefaultContext) -> Content + private let startDate = Date() + @State private var context: MenuBarTimelineViewDefaultContext = .init(date: .now) init( @@ -29,8 +31,8 @@ struct MenuBarTimelineView: View var body: some View { content(context) - .task { - for date in schedule.entries(from: .now, mode: .normal) { + .task(id: startDate) { + for date in schedule.entries(from: startDate, mode: .normal) { let duration: Duration = .init(timeInterval: date.timeIntervalSinceNow) if duration > .zero { do {