tangled
alpha
login
or
join now
coreyja.com
/
backup-blue
1
fork
atom
this repo has no description
1
fork
atom
overview
issues
pulls
pipelines
Select account when added
Corey Alexander
4 months ago
27a9e49b
f88d5ddf
+14
-7
1 changed file
expand all
collapse all
unified
split
AtProtoBackup
ContentView.swift
+14
-7
AtProtoBackup/ContentView.swift
···
15
15
@State private var inputText = ""
16
16
@State private var isLoading = false
17
17
@State private var errorMessage: String?
18
18
+
@State private var selectedAccount: PersistentIdentifier?
18
19
19
20
var body: some View {
20
21
NavigationSplitView {
21
21
-
List {
22
22
+
List(selection: $selectedAccount) {
22
23
ForEach(items) { item in
23
23
-
NavigationLink {
24
24
-
AccountDetailView(account: item)
25
25
-
} label: {
26
26
-
AccountListItemView(account: item)
27
27
-
}
24
24
+
AccountListItemView(account: item)
25
25
+
.tag(item.id)
28
26
}
29
27
.onDelete(perform: deleteItems)
30
28
}
···
44
42
}
45
43
}
46
44
} detail: {
47
47
-
Text("Select an item")
45
45
+
if let selectedId = selectedAccount,
46
46
+
let account = items.first(where: { $0.id == selectedId }) {
47
47
+
AccountDetailView(account: account)
48
48
+
} else {
49
49
+
Text("Select an item")
50
50
+
}
48
51
}
49
52
.onAppear {
50
53
discoverAndAddBackedUpAccounts()
···
96
99
let account = Account(did: parsed.did, handle: inputText, pds: parsed.pds, jsonResponse: jsonData)
97
100
modelContext.insert(account)
98
101
print("[ContentView] Account inserted into modelContext")
102
102
+
103
103
+
// Auto-select the newly added account
104
104
+
selectedAccount = account.id
105
105
+
print("[ContentView] Auto-selected new account: \(account.id)")
99
106
}
100
107
showingAlert = false
101
108
inputText = ""