Skip to content

Commit a8923d3

Browse files
committed
#RI-5087 - fix reset connection if already connected
1 parent e1e64b4 commit a8923d3

File tree

1 file changed

+11
-5
lines changed
  • redisinsight/ui/src/slices/oauth

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,20 @@ export const oauthCapiKeysSelector = (state: RootState) => state.oauth.cloud.cap
236236
export default oauthCloudSlice.reducer
237237

238238
export function createFreeDbSuccess(id: string, history: any) {
239-
return async (dispatch: AppDispatch) => {
239+
return async (dispatch: AppDispatch, stateInit: () => RootState) => {
240240
try {
241241
const onConnect = () => {
242-
dispatch(resetKeys())
243-
dispatch(setAppContextInitialState())
244-
dispatch(setConnectedInstanceId(id ?? ''))
242+
const state = stateInit()
243+
const isConnected = state.app?.context?.contextInstanceId === id
244+
245245
dispatch(removeInfiniteNotification(InfiniteMessagesIds.oAuthSuccess))
246-
dispatch(checkConnectToInstanceAction(id))
246+
247+
if (!isConnected) {
248+
dispatch(resetKeys())
249+
dispatch(setAppContextInitialState())
250+
dispatch(setConnectedInstanceId(id ?? ''))
251+
dispatch(checkConnectToInstanceAction(id))
252+
}
247253

248254
history.push(Pages.workbench(id))
249255
}

0 commit comments

Comments
 (0)