Skip to content

Commit b42093f

Browse files
committed
fix: crash on re-open app on macOS
Signed-off-by: Tommy van der Vorst <tommy@pixelspark.nl>
1 parent 3d68a3a commit b42093f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Sushitrain/App.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,9 @@ struct SushitrainApp: App {
238238
}
239239
.windowResizability(.contentSize)
240240

241-
MenuBarExtraView(hideInDock: $hideInDock)
242-
.environment(appState)
241+
// Pass app state object explicitly, as sometimes Environment fails to resolve
242+
// for some reason...
243+
MenuBarExtraView(appState: appState, hideInDock: $hideInDock)
243244

244245
Settings {
245246
NavigationStack {
@@ -267,9 +268,9 @@ struct SushitrainApp: App {
267268

268269
#if os(macOS)
269270
struct MenuBarExtraView: Scene {
271+
let appState: AppState
270272
@Binding var hideInDock: Bool
271273
@Environment(\.openWindow) private var openWindow
272-
@Environment(AppState.self) private var appState
273274

274275
@State private var folders: [SushitrainFolder] = []
275276

@@ -278,11 +279,12 @@ struct SushitrainApp: App {
278279
NavigationStack {
279280
TabbedSettingsView(hideInDock: $hideInDock)
280281
}
281-
}
282+
}.environment(appState)
282283

283284
MenuBarExtra("Synctrain", systemImage: self.menuIcon, isInserted: $hideInDock) {
284285
if appState.startupState == .started {
285286
OverallStatusView()
287+
.environment(appState)
286288
.task {
287289
await self.update()
288290
}

0 commit comments

Comments
 (0)