--- a/TalerWallet1/Views/TalDir/AddContactView.swift +++ b/TalerWallet1/Views/TalDir/AddContactView.swift @@ -21,6 +21,7 @@ @EnvironmentObject private var model: WalletModel @EnvironmentObject private var controller: Controller + @Environment(\.dismiss) private var dismiss @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic @State private var created: Bool = false @@ -203,13 +204,21 @@ Task { do { try await model.addContact(newContact) - } catch { // it didn't succeed + self.working = false + if url != nil { + dismissTop(stack.push()) // opened from a link: close the sheet + } else { + // reached from the contacts list (or after registering an alias): go back + // ONE level. dismissTop() pops to the root when there is no sheet, which + // left the user on the start page, three levels above the list. + dismiss() + } + } catch { // it didn't succeed: stay here, so that the error state can be seen // TODO: show error print("addContact failed") lookupState = .error + self.working = false } - self.working = false - dismissTop(stack.push()) } } }