+layout.ts (717B)
1 2 import { datastore, nostr_keys, route } from '$lib/utils/app'; 3 import type { AppData } from '$lib/utils/config'; 4 import { handle_err } from '@radroots/apps-lib'; 5 import type { LayoutLoad, LayoutLoadEvent } from './$types'; 6 7 export const load: LayoutLoad = async (_: LayoutLoadEvent) => { 8 try { 9 await datastore.init(); 10 const app_data = await datastore.get_obj<AppData>("app_data"); 11 if ("result" in app_data) { 12 const nostr_key = await nostr_keys.read(app_data.result.active_key); 13 if ("result" in nostr_key) return void await route(`/`); 14 // @todo 15 } 16 } catch (e) { 17 handle_err(e, `(cfg)load`) 18 } finally { 19 return {}; 20 }; 21 };