about summary refs log tree commit diff
path: root/src/screens/Signup/index.tsx
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-08-22 22:43:23 +0100
committerGitHub <noreply@github.com>2024-08-22 22:43:23 +0100
commit27bb3832683275be0c778a38c526bfd55cebee59 (patch)
tree02b0e1a9c802b0f75ac33d3e00daa95203e322cc /src/screens/Signup/index.tsx
parentdf5bf28e614150bda5d58b22b7db308f71f70e07 (diff)
downloadvoidsky-27bb3832683275be0c778a38c526bfd55cebee59.tar.zst
Submit fix (#4978)
* Fix submit logic

* Fix type

* Align submit task creation 1:1 with callsites

* blegh. `useThrottledValue`

* make `useThrottledValue`'s time required

---------

Co-authored-by: Hailey <me@haileyok.com>
Diffstat (limited to 'src/screens/Signup/index.tsx')
-rw-r--r--src/screens/Signup/index.tsx11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/screens/Signup/index.tsx b/src/screens/Signup/index.tsx
index 189760460..0e1a2e61f 100644
--- a/src/screens/Signup/index.tsx
+++ b/src/screens/Signup/index.tsx
@@ -16,6 +16,7 @@ import {
   reducer,
   SignupContext,
   SignupStep,
+  useSubmitSignup,
 } from '#/screens/Signup/state'
 import {StepCaptcha} from '#/screens/Signup/StepCaptcha'
 import {StepHandle} from '#/screens/Signup/StepHandle'
@@ -33,6 +34,7 @@ export function Signup({onPressBack}: {onPressBack: () => void}) {
   const {screen} = useAnalytics()
   const [state, dispatch] = React.useReducer(reducer, initialState)
   const {gtMobile} = useBreakpoints()
+  const submit = useSubmitSignup()
 
   const activeStarterPack = useActiveStarterPack()
   const {
@@ -81,6 +83,15 @@ export function Signup({onPressBack}: {onPressBack: () => void}) {
     }
   }, [_, serviceInfo, isError])
 
+  React.useEffect(() => {
+    if (state.pendingSubmit) {
+      if (!state.pendingSubmit.mutableProcessed) {
+        state.pendingSubmit.mutableProcessed = true
+        submit(state, dispatch)
+      }
+    }
+  }, [state, dispatch, submit])
+
   return (
     <SignupContext.Provider value={{state, dispatch}}>
       <LoggedOutLayout