From f3834ab9fef93773ad3f2063b38468b2fed51325 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kuty=C5=82a?= Date: Fri, 8 Jan 2021 21:59:27 +0100 Subject: [PATCH] 17231: Added timeout to allow app to load properly before redirect MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła 01~ --- src/views-components/api-token/api-token.tsx | 25 +++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/views-components/api-token/api-token.tsx b/src/views-components/api-token/api-token.tsx index b282311814..548dfe7722 100644 --- a/src/views-components/api-token/api-token.tsx +++ b/src/views-components/api-token/api-token.tsx @@ -11,6 +11,7 @@ import { AuthService } from "~/services/auth-service/auth-service"; import { navigateToRootProject, navigateToLinkAccount } from "~/store/navigation/navigation-action"; import { Config } from "~/common/config"; import { getAccountLinkData } from "~/store/link-account-panel/link-account-panel-actions"; +import { replace } from "react-router-redux"; interface ApiTokenProps { authService: AuthService; @@ -27,18 +28,20 @@ export const ApiToken = connect()( this.props.dispatch(saveApiToken(apiToken)).finally(() => { const redirectURL = this.props.authService.getTargetURL(); - if (loadMainApp) { - if (redirectURL) { - this.props.authService.removeTargetURL(); - window.location.href = redirectURL; + setTimeout(() => { + if (loadMainApp) { + if (redirectURL) { + this.props.authService.removeTargetURL(); + this.props.dispatch(replace(redirectURL)); + } + else if (this.props.dispatch(getAccountLinkData())) { + this.props.dispatch(navigateToLinkAccount); + } + else { + this.props.dispatch(navigateToRootProject); + } } - else if (this.props.dispatch(getAccountLinkData())) { - this.props.dispatch(navigateToLinkAccount); - } - else { - this.props.dispatch(navigateToRootProject); - } - } + }, 0); }); } render() { -- 2.30.2