From 0fe9edfdbc8b7862914c3a1db689cd7b630508ff Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 12 Nov 2022 22:54:55 -0500 Subject: [PATCH] Fix crash when opening Drafts screen on macOS --- Tusker/Screens/Compose/ComposeView.swift | 2 +- Tusker/Screens/Compose/DraftsView.swift | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Tusker/Screens/Compose/ComposeView.swift b/Tusker/Screens/Compose/ComposeView.swift index 6d74e4cd2b..977951ffc2 100644 --- a/Tusker/Screens/Compose/ComposeView.swift +++ b/Tusker/Screens/Compose/ComposeView.swift @@ -111,7 +111,7 @@ struct ComposeView: View { }) .navigationTitle(navTitle) .sheet(isPresented: $uiState.isShowingDraftsList) { - DraftsView(currentDraft: draft) + DraftsView(currentDraft: draft, mastodonController: mastodonController) } .actionSheet(isPresented: $uiState.isShowingSaveDraftSheet, content: self.saveAndCloseSheet) .alert(isPresented: $isShowingPostErrorAlert) { diff --git a/Tusker/Screens/Compose/DraftsView.swift b/Tusker/Screens/Compose/DraftsView.swift index f2348b7fb9..733d90e1f7 100644 --- a/Tusker/Screens/Compose/DraftsView.swift +++ b/Tusker/Screens/Compose/DraftsView.swift @@ -10,8 +10,9 @@ import SwiftUI struct DraftsView: View { let currentDraft: Draft + // don't pass this in via the environment b/c it crashes on macOS (at least, in Designed for iPad mode) since the environment doesn't get propagated through the modal popup window or something + let mastodonController: MastodonController @EnvironmentObject var uiState: ComposeUIState - @EnvironmentObject var mastodonController: MastodonController @StateObject private var draftsManager = DraftsManager.shared @State private var draftForDifferentReply: Draft? @@ -112,8 +113,8 @@ struct DraftView: View { } } -struct DraftsView_Previews: PreviewProvider { - static var previews: some View { - DraftsView(currentDraft: Draft(accountID: "")) - } -} +//struct DraftsView_Previews: PreviewProvider { +// static var previews: some View { +// DraftsView(currentDraft: Draft(accountID: "")) +// } +//}