Don't open for logged out users
parent
2ee68e4f4d
commit
f8edd11bc5
|
@ -87,6 +87,11 @@ function Frame({children}: {children: React.ReactNode}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TenMillion() {
|
export function TenMillion() {
|
||||||
|
const {hasSession} = useSession()
|
||||||
|
return hasSession ? <TenMillionInner /> : null
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TenMillionInner() {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const lightTheme = useTheme('light')
|
const lightTheme = useTheme('light')
|
||||||
const {_, i18n} = useLingui()
|
const {_, i18n} = useLingui()
|
||||||
|
@ -96,7 +101,7 @@ export function TenMillion() {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const {isLoading: isProfileLoading, data: profile} = useProfileQuery({
|
const {isLoading: isProfileLoading, data: profile} = useProfileQuery({
|
||||||
did: currentAccount!.did,
|
did: currentAccount!.did,
|
||||||
}) // TODO PWI
|
})
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
const moderation = React.useMemo(() => {
|
const moderation = React.useMemo(() => {
|
||||||
return profile && moderationOpts
|
return profile && moderationOpts
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
|
import {useSession} from '#/state/session'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
|
|
||||||
import {TenMillion} from '#/components/dialogs/nudges/TenMillion'
|
import {TenMillion} from '#/components/dialogs/nudges/TenMillion'
|
||||||
|
|
||||||
type Context = {
|
type Context = {
|
||||||
|
@ -12,7 +12,7 @@ type Context = {
|
||||||
|
|
||||||
const Context = React.createContext<Context>({
|
const Context = React.createContext<Context>({
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
controls: {}
|
controls: {},
|
||||||
})
|
})
|
||||||
|
|
||||||
export function useContext() {
|
export function useContext() {
|
||||||
|
@ -22,17 +22,20 @@ export function useContext() {
|
||||||
let SHOWN = false
|
let SHOWN = false
|
||||||
|
|
||||||
export function NudgeDialogs() {
|
export function NudgeDialogs() {
|
||||||
|
const {hasSession} = useSession()
|
||||||
const tenMillion = Dialog.useDialogControl()
|
const tenMillion = Dialog.useDialogControl()
|
||||||
|
|
||||||
const ctx = React.useMemo(() => {
|
const ctx = React.useMemo(() => {
|
||||||
return {
|
return {
|
||||||
controls: {
|
controls: {
|
||||||
tenMillion
|
tenMillion,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}, [tenMillion])
|
}, [tenMillion])
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
if (!hasSession) return
|
||||||
|
|
||||||
const t = setTimeout(() => {
|
const t = setTimeout(() => {
|
||||||
if (!SHOWN) {
|
if (!SHOWN) {
|
||||||
SHOWN = true
|
SHOWN = true
|
||||||
|
@ -43,7 +46,7 @@ export function NudgeDialogs() {
|
||||||
return () => {
|
return () => {
|
||||||
clearTimeout(t)
|
clearTimeout(t)
|
||||||
}
|
}
|
||||||
}, [ctx])
|
}, [ctx, hasSession])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Context.Provider value={ctx}>
|
<Context.Provider value={ctx}>
|
||||||
|
|
Loading…
Reference in New Issue