commit 39a866ae77ee75aeb08b917165662f2cee0df29e
parent 147e56fd289606ed689e3dd8c902543d01c3f4d7
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:
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);
}
}}
>