diff --git a/src/app/components/SpaceSearch.svelte b/src/app/components/SpaceSearch.svelte index 687555ad..b1143fec 100644 --- a/src/app/components/SpaceSearch.svelte +++ b/src/app/components/SpaceSearch.svelte @@ -20,22 +20,15 @@ const {url, h}: Props = $props() - type SearchScope = "room" | "space" - - const scopes: SearchScope[] = h ? ["room", "space"] : ["space"] - let term = $state("") let show = $state(false) - let scope = $state(h ? "room" : "space") let results = $state([]) let loading = $state(false) let input: HTMLInputElement | undefined = $state() let controller: AbortController | undefined const relayStatus = $derived( - scope === "room" - ? `Using space relay: ${url} (room filter applied).` - : `Using space relay: ${url}.`, + h ? `Searching this room on relay: ${url}.` : `Searching this space on relay: ${url}.`, ) const open = () => { @@ -58,13 +51,10 @@ const getRelayUrls = () => [url] - const getFilter = (searchTerm: string): Filter => { - if (scope === "room" && h) { - return {kinds: CONTENT_KINDS, "#h": [h], search: searchTerm} - } - - return {kinds: CONTENT_KINDS, search: searchTerm} - } + const getFilter = (searchTerm: string): Filter => + h + ? {kinds: CONTENT_KINDS, "#h": [h], search: searchTerm} + : {kinds: CONTENT_KINDS, search: searchTerm} const search = debounce(300, async (searchTerm: string) => { controller?.abort() @@ -100,11 +90,6 @@ void search(term) } - const setScope = (value: SearchScope) => { - scope = value - void search(term) - } - const eventsByAge = $derived(groupBy(e => getAgeSection(e.created_at), results)) const getAgeSection = (createdAt: number) => { @@ -168,25 +153,14 @@ bind:value={term} class="min-w-0 grow" type="text" - placeholder={scope === "room" ? "Search this room..." : "Search this space..."} + placeholder={h ? "Search this room..." : "Search this space..."} oninput={onInput} /> -
- {#each scopes as value (value)} - - {/each} -

{relayStatus}

{#if !term}

- {scope === "room" - ? "Search for content in this room." - : "Search for content in this space."} + {h ? "Search for content in this room." : "Search for content in this space."}

{:else if loading}

Searching...