Skip to content

Commit

Permalink
Refresh web page when instance changed
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh committed Apr 3, 2022
1 parent f8e204b commit 4aeebe8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 5 additions & 1 deletion components/dashboard/src/start/StartWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,11 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,

// Redirect to workspaceURL if we are not yet running in an iframe.
// It happens this late if we were waiting for a docker build.
if (!this.props.runsInIFrame && workspaceInstance.ideUrl && !this.props.dontAutostart) {
if (
!this.props.runsInIFrame &&
workspaceInstance.ideUrl &&
(!this.props.dontAutostart || workspaceInstance.status.phase === "running")
) {
this.redirectTo(workspaceInstance.ideUrl);
return;
}
Expand Down
13 changes: 12 additions & 1 deletion components/supervisor/frontend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,20 @@ const toStop = new DisposableCollection();
//#region current-frame
let current: HTMLElement = loading.frame;
let desktopRedirected = false;
let currentInstanceId = "";
const nextFrame = () => {
const instance = gitpodServiceClient.info.latestInstance;
if (instance) {
// refresh web page when instanceId changed
if (currentInstanceId !== "") {
if (instance.id !== currentInstanceId && instance.ideUrl !== "") {
currentInstanceId = instance.id;
window.location.href = instance.ideUrl;
return;
}
} else {
currentInstanceId = instance.id;
}
if (instance.status.phase === 'running') {
if (!hideDesktopIde) {
if (isDesktopIde == undefined) {
Expand Down Expand Up @@ -148,7 +159,7 @@ const toStop = new DisposableCollection();
}
const updateCurrentFrame = () => {
const newCurrent = nextFrame();
if (current === newCurrent) {
if (newCurrent == null || current === newCurrent) {
return;
}
current.style.visibility = 'hidden';
Expand Down

0 comments on commit 4aeebe8

Please sign in to comment.