about summary refs log tree commit diff
path: root/src/components/dialogs/nuxs/index.tsx
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2024-09-11 20:01:27 -0500
committerEric Bailey <git@esb.lol>2024-09-11 20:01:27 -0500
commit63444052e8db9d2333b887a5ba5fd261e7df52db (patch)
treeef2fde6d2ab21bcbdbac030734e81d349ead2651 /src/components/dialogs/nuxs/index.tsx
parent77d60a5b8047c2a4b18206e99d89d25222b4601c (diff)
downloadvoidsky-63444052e8db9d2333b887a5ba5fd261e7df52db.tar.zst
Rename
Diffstat (limited to 'src/components/dialogs/nuxs/index.tsx')
-rw-r--r--src/components/dialogs/nuxs/index.tsx56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/components/dialogs/nuxs/index.tsx b/src/components/dialogs/nuxs/index.tsx
new file mode 100644
index 000000000..401dd3e66
--- /dev/null
+++ b/src/components/dialogs/nuxs/index.tsx
@@ -0,0 +1,56 @@
+import React from 'react'
+
+import {useSession} from '#/state/session'
+import * as Dialog from '#/components/Dialog'
+import {TenMillion} from '#/components/dialogs/nuxs/TenMillion'
+
+type Context = {
+  controls: {
+    tenMillion: Dialog.DialogOuterProps['control']
+  }
+}
+
+const Context = React.createContext<Context>({
+  // @ts-ignore
+  controls: {},
+})
+
+export function useContext() {
+  return React.useContext(Context)
+}
+
+let SHOWN = false
+
+export function NuxDialogs() {
+  const {hasSession} = useSession()
+  const tenMillion = Dialog.useDialogControl()
+
+  const ctx = React.useMemo(() => {
+    return {
+      controls: {
+        tenMillion,
+      },
+    }
+  }, [tenMillion])
+
+  React.useEffect(() => {
+    if (!hasSession) return
+
+    const t = setTimeout(() => {
+      if (!SHOWN) {
+        SHOWN = true
+        ctx.controls.tenMillion.open()
+      }
+    }, 2e3)
+
+    return () => {
+      clearTimeout(t)
+    }
+  }, [ctx, hasSession])
+
+  return (
+    <Context.Provider value={ctx}>
+      <TenMillion />
+    </Context.Provider>
+  )
+}