Skip to content

Commit

Permalink
Refresh web page when instanceId 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 e353cd1
Showing 1 changed file with 12 additions and 1 deletion.
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 e353cd1

Please sign in to comment.