From 89839baddf646905f66762066d28f414d05a0858 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Wed, 17 Aug 2022 00:34:59 +0200 Subject: [PATCH] Fix remove instance/account button on macOS --- macOS/InstancesSettings.swift | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/macOS/InstancesSettings.swift b/macOS/InstancesSettings.swift index cd848fd6..cd28d8c9 100644 --- a/macOS/InstancesSettings.swift +++ b/macOS/InstancesSettings.swift @@ -9,9 +9,6 @@ struct InstancesSettings: View { @State private var presentingInstanceForm = false @State private var savedFormInstanceID: Instance.ID? - @State private var presentingAccountRemovalConfirmation = false - @State private var presentingInstanceRemovalConfirmation = false - @State private var frontendURL = "" @State private var proxiesVideos = false @@ -53,7 +50,18 @@ struct InstancesSettings: View { Spacer() Button("Remove") { - presentingAccountRemovalConfirmation = true + settings.presentAlert( + Alert( + title: Text( + "Are you sure you want to remove \(selectedAccount?.description ?? "") account?" + ), + message: Text("This cannot be reverted"), + primaryButton: .destructive(Text("Remove")) { + AccountsModel.remove(selectedAccount!) + }, + secondaryButton: .cancel() + ) + ) } .foregroundColor(colorScheme == .dark ? .white : .red) .opacity(account == selectedAccount ? 1 : 0) @@ -61,18 +69,6 @@ struct InstancesSettings: View { .tag(account) } } - .alert(isPresented: $presentingAccountRemovalConfirmation) { - Alert( - title: Text( - "Are you sure you want to remove \(selectedAccount?.description ?? "") account?" - ), - message: Text("This cannot be undone"), - primaryButton: .destructive(Text("Remove")) { - AccountsModel.remove(selectedAccount!) - }, - secondaryButton: .cancel() - ) - } if #available(macOS 12.0, *) { list @@ -127,12 +123,11 @@ struct InstancesSettings: View { Spacer() Button("Remove Location") { - presentingInstanceRemovalConfirmation = true settings.presentAlert(Alert( title: Text( "Are you sure you want to remove \(selectedInstance!.longDescription) location?" ), - message: Text("This cannot be undone"), + message: Text("This cannot be reverted"), primaryButton: .destructive(Text("Remove")) { if accounts.current?.instance == selectedInstance { accounts.setCurrent(nil)