From f8edd11bc5788666e0e6d55c1082971c901f089e Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 11 Sep 2024 09:57:37 -0500 Subject: [PATCH] Don't open for logged out users --- src/components/dialogs/nudges/TenMillion/index.tsx | 7 ++++++- src/components/dialogs/nudges/index.tsx | 13 ++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/components/dialogs/nudges/TenMillion/index.tsx b/src/components/dialogs/nudges/TenMillion/index.tsx index f42cd228..c2c6926f 100644 --- a/src/components/dialogs/nudges/TenMillion/index.tsx +++ b/src/components/dialogs/nudges/TenMillion/index.tsx @@ -87,6 +87,11 @@ function Frame({children}: {children: React.ReactNode}) { } export function TenMillion() { + const {hasSession} = useSession() + return hasSession ? : null +} + +export function TenMillionInner() { const t = useTheme() const lightTheme = useTheme('light') const {_, i18n} = useLingui() @@ -96,7 +101,7 @@ export function TenMillion() { const {currentAccount} = useSession() const {isLoading: isProfileLoading, data: profile} = useProfileQuery({ did: currentAccount!.did, - }) // TODO PWI + }) const moderationOpts = useModerationOpts() const moderation = React.useMemo(() => { return profile && moderationOpts diff --git a/src/components/dialogs/nudges/index.tsx b/src/components/dialogs/nudges/index.tsx index 357d4e2b..eabe60c1 100644 --- a/src/components/dialogs/nudges/index.tsx +++ b/src/components/dialogs/nudges/index.tsx @@ -1,7 +1,7 @@ import React from 'react' +import {useSession} from '#/state/session' import * as Dialog from '#/components/Dialog' - import {TenMillion} from '#/components/dialogs/nudges/TenMillion' type Context = { @@ -12,7 +12,7 @@ type Context = { const Context = React.createContext({ // @ts-ignore - controls: {} + controls: {}, }) export function useContext() { @@ -22,17 +22,20 @@ export function useContext() { let SHOWN = false export function NudgeDialogs() { + const {hasSession} = useSession() const tenMillion = Dialog.useDialogControl() const ctx = React.useMemo(() => { return { controls: { - tenMillion - } + tenMillion, + }, } }, [tenMillion]) React.useEffect(() => { + if (!hasSession) return + const t = setTimeout(() => { if (!SHOWN) { SHOWN = true @@ -43,7 +46,7 @@ export function NudgeDialogs() { return () => { clearTimeout(t) } - }, [ctx]) + }, [ctx, hasSession]) return (