web


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

commit 1635ab7a292f207697c2a6c0dc50a5c4e60d28e5
parent ce52c6e257ffb9aa2d9b8f98aa46ea55ef9c417f
Author: triesap <137732411+triesap@users.noreply.github.com>
Date:   Sun, 15 Sep 2024 12:50:38 +0000

Edit root layout, add AppConfig

Diffstat:
Msrc/routes/+layout.svelte | 79+++++++++++++++++++++++++++++--------------------------------------------------
1 file changed, 29 insertions(+), 50 deletions(-)

diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte @@ -10,11 +10,10 @@ import { app_nostr_key, app_pwa_polyfills, app_sqlite } from "$lib/stores"; import { app_config, - app_layout, app_render, app_th, app_thc, - app_win, + AppConfig, CssStatic, kv, ndk, @@ -27,7 +26,6 @@ parse_color_mode, parse_theme_key, } from "@radroots/theme/src/utils"; - import { onMount } from "svelte"; import "../app.css"; let render_pwa = browser && lc.platform === `web`; @@ -45,26 +43,6 @@ }); } - onMount(async () => { - try { - app_win.set([window.innerHeight, window.innerWidth]); - - const prefers_dark = window.matchMedia( - `(prefers-color-scheme: dark)`, - ).matches; - - if (prefers_dark) app_thc.set(`dark`); - app_config.set(true); - } catch (e) { - console.log(`(layout mount) `, e); - } finally { - } - }); - - app_win.subscribe(([win_h, win_w]) => { - if (win_h > 800) app_layout.set("lg"); - }); - app_thc.subscribe((app_thc) => { const color_mode = parse_color_mode(app_thc); theme_set(parse_theme_key($app_th), color_mode); @@ -82,33 +60,6 @@ console.log(`(app_sqlite) connected`); }); - app_nostr_key.subscribe(async (app_nostr_key) => { - try { - if (!app_nostr_key) return; - const private_key = await lc.keystore.get( - `nostr:key:${app_nostr_key}`, - ); - if (private_key) { - for (const url of PUBLIC_NOSTR_RELAY_DEFAULTS.split(",")) - $ndk.addExplicitRelay(url); - await $ndk.connect().then(() => { - console.log(`(ndk) connected`); - }); - const setup_user = await ndk_setup_privkey({ - $ndk, - private_key, - }); - if (setup_user) { - $ndk_user = setup_user; - $ndk_user.ndk = $ndk; - console.log(`(ndk_user) connected`); - } - } - } catch (e) { - console.log(`(app_nostr_key) error `, e); - } - }); - app_config.subscribe(async (app_config) => { try { if (!app_config) return; @@ -158,6 +109,33 @@ await lc.window.splash_hide(); } }); + + app_nostr_key.subscribe(async (app_nostr_key) => { + try { + if (!app_nostr_key) return; + const private_key = await lc.keystore.get( + `nostr:key:${app_nostr_key}`, + ); + if (private_key) { + for (const url of PUBLIC_NOSTR_RELAY_DEFAULTS.split(",")) + $ndk.addExplicitRelay(url); + await $ndk.connect().then(() => { + console.log(`(ndk) connected`); + }); + const setup_user = await ndk_setup_privkey({ + $ndk, + private_key, + }); + if (setup_user) { + $ndk_user = setup_user; + $ndk_user.ndk = $ndk; + console.log(`(ndk_user) connected`); + } + } + } catch (e) { + console.log(`(app_nostr_key) error `, e); + } + }); </script> <svelte:head> @@ -168,6 +146,7 @@ {#if $app_render} <slot /> {/if} +<AppConfig /> <CssStatic /> <div class="hidden h-nav_base pt-h_nav_base pb-h_nav_base h-nav_lg pt-h_nav_lg pb-h_nav_lg h-tabs_base pt-h_tabs_base pb-h_tabs_base h-tabs_lg pt-h_tabs_lg pb-h_tabs_lg top-dim_map_offset_top_base top-dim_map_offset_top_lg"