Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
fix: timeout ws connection
Browse files Browse the repository at this point in the history
  • Loading branch information
mayuran-deriv committed Jul 5, 2024
1 parent ba432b0 commit 24bd127
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useForm } from 'react-hook-form'
import { navigate } from 'gatsby'
import { getCookiesFields, getCookiesObject, getDataObjFromCookies } from 'common/cookies'
import { validation_regex } from 'common/validation'
import apiManager from 'common/websocket'
import apiManager, { ApiManager } from 'common/websocket'
import { getLanguage, isBrowser } from 'common/utility'

const getVerifyEmailRequest = (formatted_email: string) => {
Expand Down Expand Up @@ -58,13 +58,22 @@ const useSignupForm = (options?: TSignupFormOptions) => {
resolver: yupResolver(schema),
})

const onSignup = ({ email }: FormData) => {
const onSignup = async ({ email }: FormData) => {
Analytics?.trackEvent('ce_virtual_signup_form', {
action: 'started',
signup_provider: 'email',
...analyticsData,
})

const readyState = parseInt(ApiManager.readyState)
if (readyState !== 1 && readyState !== 0) {
if (isBrowser()) {
const currentLanguage = getLanguage() ?? 'en'
try {
// Connect to WebSocket if not connected
await apiManager.reconnectIfNotConnected(currentLanguage)
} catch (e) {}
}
}
const formatted_email = getVerifyEmailRequest(email)
apiManager
.augmentedSend('verify_email', {
Expand Down

0 comments on commit 24bd127

Please sign in to comment.