Skip to content

Commit

Permalink
Fix banner <> redirect race
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptronicek committed Dec 19, 2024
1 parent 9826ca5 commit 2f79564
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/dashboard/src/start/StartWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ export interface StartWorkspaceState {
* Set to prevent multiple redirects to the same URL when the User Agent ignores our wish to open links in the same tab (by setting window.location.href).
*/
redirected?: boolean;
/**
* Determines whether `redirected` has been `true` for long enough to display our "new tab" info banner without racing with same-tab redirection in regular setups
*/
showRedirectMessage?: boolean;
}

// TODO: use Function Components
Expand Down Expand Up @@ -474,6 +478,9 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
}

this.setState({ redirected: true });
setTimeout(() => {
this.setState({ showRedirectMessage: true });
}, 2000);
}

private openDesktopLink(link: string) {
Expand Down Expand Up @@ -767,7 +774,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
workspaceId={this.props.workspaceId}
>
{statusMessage}
{this.state.redirected && (
{this.state.showRedirectMessage && (
<>
<Alert type="info" className="mt-4 w-112">
We redirected you to your workspace, but your browser probably opened it in another tab.
Expand Down

0 comments on commit 2f79564

Please sign in to comment.