From 5d033cbdfc0f8163905148aa1b900565866008b8 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Fri, 11 Nov 2022 19:23:58 +0100 Subject: [PATCH] Use anonymous account after adding first instance --- Shared/Settings/InstanceForm.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Shared/Settings/InstanceForm.swift b/Shared/Settings/InstanceForm.swift index 56d06283..6fe27011 100644 --- a/Shared/Settings/InstanceForm.swift +++ b/Shared/Settings/InstanceForm.swift @@ -16,6 +16,8 @@ struct InstanceForm: View { @Environment(\.colorScheme) private var colorScheme @Environment(\.presentationMode) private var presentationMode + @EnvironmentObject private var accounts + var body: some View { VStack(alignment: .leading) { Group { @@ -138,7 +140,12 @@ struct InstanceForm: View { return } - savedInstanceID = InstancesModel.add(app: app, name: name, url: url).id + let savedInstance = InstancesModel.add(app: app, name: name, url: url) + savedInstanceID = savedInstance.id + + if accounts.isEmpty { + accounts.setCurrent(savedInstance.anonymousAccount) + } presentationMode.wrappedValue.dismiss() }