From 4b1450a0faa365046a1569a2862684e5be1767c3 Mon Sep 17 00:00:00 2001 From: Roman Sergeenko Date: Fri, 28 Jul 2023 13:06:01 +0200 Subject: [PATCH] #RI-4779 - fix behaviour on open application --- .../views/cloud_outh_callback/index.js | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/redisinsight/desktop/views/cloud_outh_callback/index.js b/redisinsight/desktop/views/cloud_outh_callback/index.js index bc6b22e894..34c0e63f19 100644 --- a/redisinsight/desktop/views/cloud_outh_callback/index.js +++ b/redisinsight/desktop/views/cloud_outh_callback/index.js @@ -1,20 +1,25 @@ -const protocol = 'redisinsight://'; -const callbackUrl = 'cloud/oauth/callback'; +const protocol = 'redisinsight://' +const callbackUrl = 'cloud/oauth/callback' -const openAppButton = document.querySelector('#open-app'); +const openAppButton = document.querySelector('#open-app') -const openApp = () => { +const openApp = (forceOpen) => { try { - const currentUrl = new URL(window.location.href); - const redirectUrl = protocol + callbackUrl + currentUrl.search; + const currentUrl = new URL(window.location.href) + const redirectUrl = protocol + callbackUrl + currentUrl.search + const isOpened = window.location.hash === '#success' - window.location.href = redirectUrl.toString(); + if (forceOpen || !isOpened) { + window.location.href = redirectUrl.toString() + } + + window.location.hash = '#success' } catch (_e) { // } -}; +} // handlers -openAppButton.addEventListener('click', openApp); +openAppButton.addEventListener('click', () => openApp(true)) -openApp(); +openApp()