diff --git a/src/components/Article/ShoutRatingControl.tsx b/src/components/Article/ShoutRatingControl.tsx index 7e0f22cb..0352e9db 100644 --- a/src/components/Article/ShoutRatingControl.tsx +++ b/src/components/Article/ShoutRatingControl.tsx @@ -26,7 +26,7 @@ export const ShoutRatingControl = (props: ShoutRatingControlProps) => { const { reactionEntities, - actions: { createReaction, deleteReaction, loadReactionsBy }, + actions: { createReaction, loadReactionsBy }, } = useReactions() const checkReaction = (reactionKind: ReactionKind) => diff --git a/src/context/session.tsx b/src/context/session.tsx index 94a69ea0..490b09ab 100644 --- a/src/context/session.tsx +++ b/src/context/session.tsx @@ -47,7 +47,6 @@ export type SessionContextType = { authError: Accessor isSessionLoaded: Accessor subscriptions: Accessor - isAuthWithCallback: Accessor<() => void> isAuthenticated: Accessor actions: { loadSession: () => AuthToken | Promise @@ -70,6 +69,8 @@ export type SessionContextType = { } } +const noop = () => {} + const SessionContext = createContext() export function useSession() { @@ -250,11 +251,9 @@ export const SessionProvider = (props: { ), ) - // require auth wrapper - const [isAuthWithCallback, setIsAuthWithCallback] = createSignal<() => void>() + const [authCallback, setAuthCallback] = createSignal<() => void>(() => {}) const requireAuthentication = async (callback: () => void, modalSource: AuthModalSource) => { - setIsAuthWithCallback(() => callback) - + setAuthCallback((_cb) => callback) if (!session()) { await loadSession() if (!session()) { @@ -264,9 +263,10 @@ export const SessionProvider = (props: { } createEffect(() => { - if (isAuthWithCallback()) { - isAuthWithCallback()() - setIsAuthWithCallback(null) + const handler = authCallback() + if (handler !== noop) { + handler() + setAuthCallback((_cb) => noop) } }) @@ -345,7 +345,6 @@ export const SessionProvider = (props: { isSessionLoaded, author, actions, - isAuthWithCallback, isAuthenticated, }