Files
radicle-explorer/src/SeedDropdown.svelte
T
Sebastian MartinezandRūdolfs Ošiņš f8ddbbf5da Remove svelte-routing and add custom routing
Co-authored-by: Rūdolfs Ošiņš <rudolfs@osins.org>
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2022-11-07 08:57:37 +01:00

38 lines
989 B
Svelte

<script lang="ts">
import type { SeedSession } from "@app/siwe";
import * as router from "@app/router";
import Dropdown from "@app/Dropdown.svelte";
import { Seed } from "@app/base/seeds/Seed";
import { closeFocused } from "@app/Floating.svelte";
export let seeds: { [key: string]: SeedSession };
// When a user signs into a new seed we want to update the seed listing
$: formatSeeds = async () => {
return await Promise.all(
Object.values(seeds).map(async session => {
const seed = await Seed.lookup(session.domain);
const key = `${seed.emoji} ${seed.host}`;
return {
key,
value: seed.host,
title: `Go to ${seed.host}`,
badge: null,
};
}),
);
};
</script>
{#await formatSeeds() then items}
<Dropdown
{items}
selected={null}
on:select={item => {
closeFocused();
router.push({ resource: "seeds", params: { host: item.detail } });
}} />
{/await}