Skip to content

Commit 5f4407c

Browse files
authored
Merge pull request #3389 from RedisInsight/fe/bugfix/RI-5402-ai-assistant
#RI-5719 - handle double callback
2 parents d97b9f2 + 39709db commit 5f4407c

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

redisinsight/ui/src/electron/components/ConfigOAuth/ConfigOAuth.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const ConfigOAuth = () => {
2626

2727
const ssoFlowRef = useRef(ssoFlow)
2828
const isRecommendedSettingsRef = useRef(isRecommendedSettings)
29-
const isFlowStarted = useRef(!!ssoFlow)
29+
const isFlowInProgress = useRef(false)
3030

3131
const history = useHistory()
3232
const dispatch = useDispatch()
@@ -37,7 +37,10 @@ const ConfigOAuth = () => {
3737

3838
useEffect(() => {
3939
ssoFlowRef.current = ssoFlow
40-
isFlowStarted.current = !!ssoFlow
40+
41+
if (!ssoFlow) {
42+
isFlowInProgress.current = false
43+
}
4144
}, [ssoFlow])
4245

4346
useEffect(() => {
@@ -91,18 +94,23 @@ const ConfigOAuth = () => {
9194
}
9295

9396
const cloudOauthCallback = (_e: any, { status, message = '', error }: CloudAuthResponse) => {
94-
if (!isFlowStarted.current) return
95-
9697
if (status === CloudAuthStatus.Succeed) {
9798
dispatch(setJob({ id: '', name: CloudJobName.CreateFreeSubscriptionAndDatabase, status: '' }))
9899
localStorageService.remove(BrowserStorageItem.OAuthJobId)
99100
dispatch(showOAuthProgress(true))
100101
dispatch(addInfiniteNotification(INFINITE_MESSAGES.AUTHENTICATING()))
101102
dispatch(setSocialDialogState(null))
102103
dispatch(fetchUserInfo(fetchUserInfoSuccess, closeInfinityNotification))
104+
isFlowInProgress.current = true
103105
}
104106

105107
if (status === CloudAuthStatus.Failed) {
108+
// don't do anything, because we are processing something
109+
// covers situation when were made several clicks on the same time
110+
if (isFlowInProgress.current) {
111+
return
112+
}
113+
106114
const err = parseCloudOAuthError((error as CustomError) || message || '')
107115
dispatch(setOAuthCloudSource(null))
108116
dispatch(signInFailure(err?.response?.data?.message || message))

redisinsight/ui/src/slices/interfaces/cloud.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ export enum CloudSsoUtmCampaign {
109109
Tutorial = 'tutorial',
110110
TriggersAndFunctions = 'redisinsight_triggers_and_functions',
111111
AutoDiscovery = 'auto_discovery',
112-
Copilot = 'ai_chat',
113-
UserProfile = 'account',
112+
Copilot = 'copilot',
113+
UserProfile = 'user_account',
114+
Settings = 'settings',
114115
Unknown = 'other',
115116
}

redisinsight/ui/src/utils/oauth/cloudSsoUtm.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export const getCloudSsoUtmCampaign = (source?: string | null): CloudSsoUtmCampa
3131
return CloudSsoUtmCampaign.Copilot
3232
case OAuthSocialSource.UserProfile:
3333
return CloudSsoUtmCampaign.UserProfile
34+
case OAuthSocialSource.SettingsPage:
35+
return CloudSsoUtmCampaign.Settings
3436
default:
3537
return CloudSsoUtmCampaign.Unknown
3638
}

0 commit comments

Comments
 (0)