web


git clone https://radroots.dev/git/web.git
Log | Files | Refs | Submodules | README | LICENSE

commit d6ff320baa68eebde0a78b904e1b43f2909e9aad
parent a9ecd5438900e8827c07674fcf65af3c6dcf3b54
Author: triesap <137732411+triesap@users.noreply.github.com>
Date:   Sat, 31 Aug 2024 17:14:42 +0000

Add routing parameter to restart() util, update (conf)

Diffstat:
Msrc/lib/utils.ts | 7++++++-
Msrc/routes/(conf)/conf/nostr/+page.svelte | 12+++++-------
2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/lib/utils.ts b/src/lib/utils.ts @@ -1,8 +1,13 @@ +import { goto } from "$app/navigation"; import { cl } from "./client"; -export const restart = async (): Promise<void> => { +export const restart = async (route_to: true | string): Promise<void> => { try { await cl.window.splash_show(); + if (route_to) { + if (route_to === true) await goto(`/`); + else await goto(route_to) + } location.reload(); } catch (e) { console.log(`(error) restart `, e); diff --git a/src/routes/(conf)/conf/nostr/+page.svelte b/src/routes/(conf)/conf/nostr/+page.svelte @@ -1,6 +1,8 @@ <script lang="ts"> import { cl } from "$lib/client"; import { _cf } from "$lib/conf"; + import { restart } from "$lib/utils"; + import { sleep } from "@radroots/svelte-lib"; </script> <div class={`flex flex-col w-full pt-16 justify-center items-center`}> @@ -14,13 +16,9 @@ sk_hex, ); if (new_key_added) { - const key_pref_added = await cl.preferences.set( - _cf.pref_key_active, - pk_hex, - ); - if (key_pref_added) { - location.reload(); - } + await cl.preferences.set(_cf.pref_key_active, pk_hex); + await sleep(500); + await restart(true); } }} >