mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-04 08:27:30 +01:00
Editor: Properly close window on Catalyst
This commit is contained in:
parent
5a52eb50e9
commit
3f3ea4ff68
@ -19,6 +19,7 @@ public struct StatusEditorView: View {
|
|||||||
@Environment(Client.self) private var client
|
@Environment(Client.self) private var client
|
||||||
@Environment(CurrentAccount.self) private var currentAccount
|
@Environment(CurrentAccount.self) private var currentAccount
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
|
@Environment(\.dismissWindow) private var dismissWindow
|
||||||
@Environment(\.modelContext) private var context
|
@Environment(\.modelContext) private var context
|
||||||
|
|
||||||
@State private var viewModel: StatusEditorViewModel
|
@State private var viewModel: StatusEditorViewModel
|
||||||
@ -88,7 +89,7 @@ public struct StatusEditorView: View {
|
|||||||
viewModel.preferences = preferences
|
viewModel.preferences = preferences
|
||||||
viewModel.prepareStatusText()
|
viewModel.prepareStatusText()
|
||||||
if !client.isAuth {
|
if !client.isAuth {
|
||||||
dismiss()
|
close()
|
||||||
NotificationCenter.default.post(name: .shareSheetClose,
|
NotificationCenter.default.post(name: .shareSheetClose,
|
||||||
object: nil)
|
object: nil)
|
||||||
}
|
}
|
||||||
@ -140,7 +141,7 @@ public struct StatusEditorView: View {
|
|||||||
if viewModel.shouldDisplayDismissWarning {
|
if viewModel.shouldDisplayDismissWarning {
|
||||||
isDismissAlertPresented = true
|
isDismissAlertPresented = true
|
||||||
} else {
|
} else {
|
||||||
dismiss()
|
close()
|
||||||
NotificationCenter.default.post(name: .shareSheetClose,
|
NotificationCenter.default.post(name: .shareSheetClose,
|
||||||
object: nil)
|
object: nil)
|
||||||
}
|
}
|
||||||
@ -153,13 +154,13 @@ public struct StatusEditorView: View {
|
|||||||
isPresented: $isDismissAlertPresented,
|
isPresented: $isDismissAlertPresented,
|
||||||
actions: {
|
actions: {
|
||||||
Button("status.draft.delete", role: .destructive) {
|
Button("status.draft.delete", role: .destructive) {
|
||||||
dismiss()
|
close()
|
||||||
NotificationCenter.default.post(name: .shareSheetClose,
|
NotificationCenter.default.post(name: .shareSheetClose,
|
||||||
object: nil)
|
object: nil)
|
||||||
}
|
}
|
||||||
Button("status.draft.save") {
|
Button("status.draft.save") {
|
||||||
context.insert(Draft(content: viewModel.statusText.string))
|
context.insert(Draft(content: viewModel.statusText.string))
|
||||||
dismiss()
|
close()
|
||||||
NotificationCenter.default.post(name: .shareSheetClose,
|
NotificationCenter.default.post(name: .shareSheetClose,
|
||||||
object: nil)
|
object: nil)
|
||||||
}
|
}
|
||||||
@ -211,7 +212,7 @@ public struct StatusEditorView: View {
|
|||||||
private func postStatus() async {
|
private func postStatus() async {
|
||||||
let status = await viewModel.postStatus()
|
let status = await viewModel.postStatus()
|
||||||
if status != nil {
|
if status != nil {
|
||||||
dismiss()
|
close()
|
||||||
SoundEffectManager.shared.playSound(of: .tootSent)
|
SoundEffectManager.shared.playSound(of: .tootSent)
|
||||||
NotificationCenter.default.post(name: .shareSheetClose,
|
NotificationCenter.default.post(name: .shareSheetClose,
|
||||||
object: nil)
|
object: nil)
|
||||||
@ -289,4 +290,12 @@ public struct StatusEditorView: View {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func close() {
|
||||||
|
if ProcessInfo.processInfo.isMacCatalystApp {
|
||||||
|
dismissWindow()
|
||||||
|
} else {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user