this repo has no description

Select account when added

+14 -7
+14 -7
AtProtoBackup/ContentView.swift
··· 15 @State private var inputText = "" 16 @State private var isLoading = false 17 @State private var errorMessage: String? 18 19 var body: some View { 20 NavigationSplitView { 21 - List { 22 ForEach(items) { item in 23 - NavigationLink { 24 - AccountDetailView(account: item) 25 - } label: { 26 - AccountListItemView(account: item) 27 - } 28 } 29 .onDelete(perform: deleteItems) 30 } ··· 44 } 45 } 46 } detail: { 47 - Text("Select an item") 48 } 49 .onAppear { 50 discoverAndAddBackedUpAccounts() ··· 96 let account = Account(did: parsed.did, handle: inputText, pds: parsed.pds, jsonResponse: jsonData) 97 modelContext.insert(account) 98 print("[ContentView] Account inserted into modelContext") 99 } 100 showingAlert = false 101 inputText = ""
··· 15 @State private var inputText = "" 16 @State private var isLoading = false 17 @State private var errorMessage: String? 18 + @State private var selectedAccount: PersistentIdentifier? 19 20 var body: some View { 21 NavigationSplitView { 22 + List(selection: $selectedAccount) { 23 ForEach(items) { item in 24 + AccountListItemView(account: item) 25 + .tag(item.id) 26 } 27 .onDelete(perform: deleteItems) 28 } ··· 42 } 43 } 44 } detail: { 45 + if let selectedId = selectedAccount, 46 + let account = items.first(where: { $0.id == selectedId }) { 47 + AccountDetailView(account: account) 48 + } else { 49 + Text("Select an item") 50 + } 51 } 52 .onAppear { 53 discoverAndAddBackedUpAccounts() ··· 99 let account = Account(did: parsed.did, handle: inputText, pds: parsed.pds, jsonResponse: jsonData) 100 modelContext.insert(account) 101 print("[ContentView] Account inserted into modelContext") 102 + 103 + // Auto-select the newly added account 104 + selectedAccount = account.id 105 + print("[ContentView] Auto-selected new account: \(account.id)") 106 } 107 showingAlert = false 108 inputText = ""