Fix broken npub searching

This commit is contained in:
William Casarin
2023-03-30 12:26:06 -04:00
parent 0a4e75bfec
commit 695699aa10

View File

@@ -46,32 +46,7 @@ struct SearchingEventView: View {
} }
} }
var body: some View { func handle_search(_ evid: String) {
Group {
switch search_state {
case .searching:
HStack(spacing: 10) {
Text("Looking for \(search_name)...", comment: "Label that appears when searching for note or profile")
ProgressView()
.progressViewStyle(.circular)
}
case .found(let ev):
NavigationLink(destination: ThreadView(state: state, thread: ThreadModel(event: ev, damus_state: state))) {
EventView(damus: state, event: ev)
}
.buttonStyle(PlainButtonStyle())
case .found_profile(let pk):
NavigationLink(destination: ProfileView(damus_state: state, pubkey: pk)) {
FollowUserView(target: .pubkey(pk), damus_state: state)
}
.buttonStyle(PlainButtonStyle())
case .not_found:
Text("\(search_name.capitalized) not found", comment: "When a note or profile is not found when searching for it via its note id")
}
}
.onChange(of: evid, debounceTime: 0.5) { evid in
self.search_state = .searching self.search_state = .searching
switch search_type { switch search_type {
@@ -127,6 +102,38 @@ struct SearchingEventView: View {
} }
} }
} }
var body: some View {
Group {
switch search_state {
case .searching:
HStack(spacing: 10) {
Text("Looking for \(search_name)...", comment: "Label that appears when searching for note or profile")
ProgressView()
.progressViewStyle(.circular)
}
case .found(let ev):
NavigationLink(destination: ThreadView(state: state, thread: ThreadModel(event: ev, damus_state: state))) {
EventView(damus: state, event: ev)
}
.buttonStyle(PlainButtonStyle())
case .found_profile(let pk):
NavigationLink(destination: ProfileView(damus_state: state, pubkey: pk)) {
FollowUserView(target: .pubkey(pk), damus_state: state)
}
.buttonStyle(PlainButtonStyle())
case .not_found:
Text("\(search_name.capitalized) not found", comment: "When a note or profile is not found when searching for it via its note id")
}
}
.onChange(of: evid, debounceTime: 0.5) { evid in
handle_search(evid)
}
.onAppear {
handle_search(evid)
}
} }
} }