Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {

rejoiningAnimation: HTMLDivElement;

reloadButton: HTMLButtonElement;
retryButton: HTMLButtonElement;

resumeButton: HTMLButtonElement;

Expand Down Expand Up @@ -65,10 +65,10 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
this.status = document.createElement('p');
this.status.innerHTML = '';

this.reloadButton = document.createElement('button');
this.reloadButton.style.display = 'none';
this.reloadButton.innerHTML = 'Retry';
this.reloadButton.addEventListener('click', this.retry.bind(this));
this.retryButton = document.createElement('button');
this.retryButton.style.display = 'none';
this.retryButton.innerHTML = 'Retry';
this.retryButton.addEventListener('click', this.retry.bind(this));

this.resumeButton = document.createElement('button');
this.resumeButton.style.display = 'none';
Expand All @@ -77,7 +77,7 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {

this.dialog.appendChild(this.rejoiningAnimation);
this.dialog.appendChild(this.status);
this.dialog.appendChild(this.reloadButton);
this.dialog.appendChild(this.retryButton);
this.dialog.appendChild(this.resumeButton);

this.overlay.appendChild(this.dialog);
Expand All @@ -96,7 +96,7 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {

this.reconnect = options?.type === 'reconnect';

this.reloadButton.style.display = 'none';
this.retryButton.style.display = 'none';
this.rejoiningAnimation.style.display = 'block';
this.status.innerHTML = 'Rejoining the server...';
this.host.style.display = 'block';
Expand All @@ -114,7 +114,7 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
this.status.innerHTML = `Rejoin failed... trying again in ${secondsToNextAttempt} ${unitText}`;
}
} else {
this.reloadButton.style.display = 'none';
this.retryButton.style.display = 'none';
this.rejoiningAnimation.style.display = 'none';
this.status.innerHTML = 'The session has been paused by the server.';
this.resumeButton.style.display = 'block';
Expand All @@ -129,13 +129,13 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
failed(): void {
this.rejoiningAnimation.style.display = 'none';
if (this.reconnect) {
this.reloadButton.style.display = 'block';
this.retryButton.style.display = 'block';
this.status.innerHTML = 'Failed to rejoin.<br />Please retry or reload the page.';
this.document.addEventListener('visibilitychange', this.retryWhenDocumentBecomesVisible);
} else {
this.status.innerHTML = 'Failed to resume the session.<br />Please reload the page.';
this.resumeButton.style.display = 'none';
this.reloadButton.style.display = 'none';
this.retryButton.style.display = 'none';
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export class UserSpecifiedDisplay implements ReconnectDisplay {

private reconnect = false;

private remote = false;

constructor(private dialog: HTMLElement, private readonly document: Document, maxRetries?: number) {
this.document = document;

Expand Down Expand Up @@ -70,10 +72,10 @@ export class UserSpecifiedDisplay implements ReconnectDisplay {
this.dispatchReconnectStateChangedEvent({ state: 'retrying', currentAttempt, secondsToNextAttempt });
}
if (options.type === 'pause') {
const remote = options.remote;
this.remote = options.remote;
this.dialog.classList.remove(UserSpecifiedDisplay.ShowClassName, UserSpecifiedDisplay.RetryingClassName);
this.dialog.classList.add(UserSpecifiedDisplay.PausedClassName);
this.dispatchReconnectStateChangedEvent({ state: 'paused', remote: remote });
this.dispatchReconnectStateChangedEvent({ state: 'paused', remote: this.remote });
}
}

Expand All @@ -90,7 +92,7 @@ export class UserSpecifiedDisplay implements ReconnectDisplay {
this.dispatchReconnectStateChangedEvent({ state: 'failed' });
} else {
this.dialog.classList.add(UserSpecifiedDisplay.ResumeFailedClassName);
this.dispatchReconnectStateChangedEvent({ state: 'resume-failed' });
this.dispatchReconnectStateChangedEvent({ state: 'resume-failed', remote: this.remote });
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function handleReconnectStateChanged(event) {
reconnectModal.close();
} else if (event.detail.state === "failed") {
document.addEventListener("visibilitychange", retryWhenDocumentBecomesVisible);
} else if (event.detail.state === "rejected") {
} else if (event.detail.state === "rejected" || (event.detail.state === "resume-failed" && event.detail.remote === true)) {
location.reload();
}
}
Expand Down
Loading