17231: Added timeout to allow app to load properly before redirect
[arvados-workbench2.git] / src / views-components / api-token / api-token.tsx
index f4b50e36d0fdbb7404ee014db80ec605ce51634b..548dfe772291690adbb5b728618033c04af6fcf1 100644 (file)
@@ -28,18 +28,20 @@ export const ApiToken = connect()(
             this.props.dispatch<any>(saveApiToken(apiToken)).finally(() => {
                 const redirectURL = this.props.authService.getTargetURL();
 
-                if (loadMainApp) {
-                    if (redirectURL) {
-                        this.props.authService.removeTargetURL();
-                        this.props.dispatch(replace(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() {