feat: use NIP-50 relay-side search with scope selection #114
Reference in New Issue
Block a user
Delete Branch ":dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Replaces the local Fuse.js-based message search in
SpaceSearchwith NIP-50 relay-side search, allowing users to search across messages that haven't been loaded locally.Addresses #110
Changes
src/app/components/SpaceSearch.sveltecreateSearch(Fuse.js) withrequest()using the NIP-50searchfilter field#htag filterHow it works
userSearchRelayList, falling back toDEFAULT_RELAYSif none are configured@hodlbod Kindly review this PR :)
@@ -23,3 +24,1 @@url,h ? [{kinds: [MESSAGE], "#h": [h]}] : [{kinds: [MESSAGE]}],)type SearchScope = "room" | "space" | "everything"Let's just stick to room/space, it probably doesn't make sense to add the everything category until we've integrated social media features (and it should probably go on the global search page).
Sure. I've removed the
everythingscope and kept the search UI limited to room and space only.@@ -45,0 +81,4 @@return {kinds: [MESSAGE], "#h": [h], search: searchTerm}}return {kinds: [MESSAGE], search: searchTerm}Use
CONTENT_KINDShere so we can search threads, events, classifieds, etcSure. I've switched the search filter to CONTENT_KINDS, so room/space search now includes threads, events, classifieds, and other supported content types.
@@ -45,0 +104,4 @@filters: [getFilter(searchTerm.trim())],})if (searchId === currentSearchId) {This logic is redundant with the abort controller, it can be removed.
Sure. I've removed the extra search ID/race tracking and relied on the AbortController for request cancellation, since that already covers the in-flight search case.
junaiddshaukat referenced this pull request2026-04-02 17:53:55 +00:00
@@ -30,0 +36,4 @@scope === "room"? `Using space relay: ${url} (room filter applied).`: `Using space relay: ${url}.`,)Let's actually remove the room/space distinction and go back to detecting based on the presence of
htag. This search is contextual to a given room, so it doesn't really make sense to search the whole relay. #59 should solve that for us one way or another.Sure. I've removed the room/space selector and restored the search to be contextual to the current room/space h-based.
@hodlbod I've made all the requested changes. Kindly review the PR :)
@hodlbod I've made the necessary changes. Kindly have a look on them :)