[ui] if query in header could be an UpEnd query, execute that

feat/vaults
Tomáš Mládek 2022-03-02 09:21:51 +01:00
parent ef3a130855
commit b6e5368a6c
No known key found for this signature in database
GPG Key ID: 65E225C8B3E2ED8A
1 changed files with 25 additions and 17 deletions

View File

@ -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}