[ui] if query in header could be an UpEnd query, execute that
parent
ef3a130855
commit
b6e5368a6c
|
@ -9,6 +9,7 @@
|
|||
import { useNavigate } from "svelte-navigator";
|
||||
import { baseSearch, createLabelled, getObjects } from "../util/search";
|
||||
import { updateTitle } from "../util/title";
|
||||
import { query as queryFn } from "../lib/entity";
|
||||
const navigate = useNavigate();
|
||||
|
||||
export let query: string;
|
||||
|
@ -19,10 +20,15 @@
|
|||
}, 200);
|
||||
$: updateQuery(query);
|
||||
|
||||
$: looksLikeQuery =
|
||||
debouncedQuery.startsWith("(") && debouncedQuery.endsWith(")");
|
||||
|
||||
let result: Readable<UpListing> = readable();
|
||||
let error: Readable<unknown> = readable();
|
||||
$: if (debouncedQuery.length) {
|
||||
({ result, error } = baseSearch(debouncedQuery));
|
||||
({ result, error } = looksLikeQuery
|
||||
? queryFn(debouncedQuery)
|
||||
: baseSearch(debouncedQuery));
|
||||
exactHits = [];
|
||||
}
|
||||
|
||||
|
@ -48,22 +54,24 @@
|
|||
|
||||
<div>
|
||||
{#if !$error}
|
||||
<section class="exact">
|
||||
{#if exactHits.length}
|
||||
<ul>
|
||||
{#each exactHits as address}
|
||||
<li>
|
||||
<UpObjectCard {address} --width="100%" --height="100%" />
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{:else}
|
||||
<div class="create">
|
||||
<div>Create new object?</div>
|
||||
<button class="create-object" on:click={create}>"{query}"</button>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
{#if !looksLikeQuery}
|
||||
<section class="exact">
|
||||
{#if exactHits.length}
|
||||
<ul>
|
||||
{#each exactHits as address}
|
||||
<li>
|
||||
<UpObjectCard {address} --width="100%" --height="100%" />
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{:else}
|
||||
<div class="create">
|
||||
<div>Create new object?</div>
|
||||
<button class="create-object" on:click={create}>"{query}"</button>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
{/if}
|
||||
{#if $result}
|
||||
<section class="objects">
|
||||
{#await objects}
|
||||
|
|
Loading…
Reference in New Issue