feat: add space search to recent activity page (#59) #119
@@ -114,7 +114,6 @@
|
||||
let loading = $state(false)
|
||||
let searchResults: TrustedEvent[] = $state([])
|
||||
let searchInput: HTMLInputElement | undefined = $state()
|
||||
let currentSearchId = 0
|
||||
let controller: AbortController | undefined
|
||||
|
||||
let limit = $state(20)
|
||||
@@ -157,7 +156,7 @@
|
||||
controller = undefined
|
||||
}
|
||||
|
||||
const search = debounce(300, async (searchTerm: string, searchId: number) => {
|
||||
const search = debounce(300, async (searchTerm: string) => {
|
||||
controller?.abort()
|
||||
|
||||
if (!searchTerm.trim()) {
|
||||
@@ -177,27 +176,19 @@
|
||||
filters: [{kinds: [MESSAGE, ...CONTENT_KINDS], search: searchTerm.trim()}],
|
||||
})
|
||||
|
||||
if (searchId === currentSearchId) {
|
||||
searchResults = sortEventsDesc(uniqBy((e: TrustedEvent) => e.id, events))
|
||||
}
|
||||
searchResults = sortEventsDesc(uniqBy((e: TrustedEvent) => e.id, events))
|
||||
|
hodlbod marked this conversation as resolved
Outdated
|
||||
} catch (error) {
|
||||
if (
|
||||
!(error instanceof DOMException && error.name === "AbortError") &&
|
||||
searchId === currentSearchId
|
||||
) {
|
||||
if (!(error instanceof DOMException && error.name === "AbortError")) {
|
||||
searchResults = []
|
||||
|
hodlbod
commented
searchId/currentSearchId are redundant with AbortController, they can be removed searchId/currentSearchId are redundant with AbortController, they can be removed
|
||||
}
|
||||
} finally {
|
||||
if (searchId === currentSearchId) {
|
||||
loading = false
|
||||
}
|
||||
loading = false
|
||||
}
|
||||
})
|
||||
|
||||
const onInput = () => {
|
||||
showSearch = true
|
||||
currentSearchId += 1
|
||||
void search(term, currentSearchId)
|
||||
void search(term)
|
||||
}
|
||||
|
||||
const onResultClick = (event: TrustedEvent) => {
|
||||
|
||||
Reference in New Issue
Block a user
Take a look at how the room search works — we should add a search icon to the PageBar which shows the same kind of popover/dialog when clicked.