Refactor search logic

- type events that are handed between components
- simplify the `resolve` function interface
  - before we had return values and exceptions, now just a single union
    type as return value
  - move navigation to the Search component to reduce its
    responsibilities
  - flatten and simplify multi-level branching
- shuffle around code
  - move the `resolve` function to the `Search` component module,
    because it's only used there

Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2022-09-29 14:50:13 +02:00
parent 01e0116029
commit d0edc52831
6 changed files with 198 additions and 165 deletions
+4 -4
View File
@@ -6,10 +6,10 @@
import Address from "@app/Address.svelte";
import Button from "@app/Button.svelte";
import { createEventDispatcher } from "svelte";
import type { ResolvedSearch } from "@app/resolver";
import type { ProjectsAndProfiles } from "@app/Search.svelte";
export let query: string;
export let results: ResolvedSearch;
export let results: ProjectsAndProfiles;
export let config: Config;
const dispatch = createEventDispatcher();
@@ -63,10 +63,10 @@
{/each}
</ul>
{/if}
{#if results.ens.length > 0}
{#if results.profiles.length > 0}
<p class="highlight txt-medium">ENS names</p>
<ul>
{#each results.ens as profile}
{#each results.profiles as profile}
<li>
<Address address={profile.address} {profile} {config} resolve />
</li>