From 070cd7ff2fd3208414abcb92d599cd5007d4bb7f Mon Sep 17 00:00:00 2001 From: Untone Date: Thu, 14 Dec 2023 16:50:22 +0300 Subject: [PATCH] session-debug-2 --- src/context/session.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/context/session.tsx b/src/context/session.tsx index 29b1f932..bfa116eb 100644 --- a/src/context/session.tsx +++ b/src/context/session.tsx @@ -16,6 +16,7 @@ import { createMemo, createResource, createSignal, + on, onMount, useContext, } from 'solid-js' @@ -93,7 +94,7 @@ export const SessionProvider = (props: { const getSession = async (): Promise => { try { const t = getToken() - console.debug('[context.session]' + t) + console.debug(t) const authResult = await authorizer().getSession({ Authorization: t, }) @@ -159,11 +160,15 @@ export const SessionProvider = (props: { }), ) - createEffect(() => { - if (props.onStateChangeCallback) { - props.onStateChangeCallback(token()) - } - }) + createEffect( + on( + () => props.onStateChangeCallback, + () => { + props.onStateChangeCallback(token()) + }, + { defer: true }, + ), + ) const [configuration, setConfig] = createSignal(config) @@ -174,7 +179,7 @@ export const SessionProvider = (props: { setConfig({ ...config, ...metaRes, redirectURL: window.location.origin + '/?modal=auth' }) console.log('[context.session] refreshing session...') const s = await getSession() - console.log(`[context.session] ${s}`) + console.debug(s) setToken(s) console.log('[context.session] loading author...') await loadAuthor()