Skip to content

Commit

Permalink
html: add ability to press enter to reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Mar 21, 2021
1 parent d4afb14 commit 9c1e464
Show file tree
Hide file tree
Showing 2 changed files with 8,845 additions and 8,822 deletions.
12 changes: 12 additions & 0 deletions html/src/components/terminal/index.tsx
Expand Up @@ -85,6 +85,7 @@ export class Xterm extends Component<Props> {
this.backoff.failAfter(15);
this.backoff.on('ready', () => {
this.backoffLock = false;
this.overlayAddon.showOverlay('Reconnecting...', null);
this.refreshToken().then(this.connect);
});
this.backoff.on('backoff', (_, delay: number) => {
Expand Down Expand Up @@ -319,6 +320,17 @@ export class Xterm extends Component<Props> {
// 1000: CLOSE_NORMAL
if (event.code !== 1000 && doBackoff && !backoffLock) {
backoff.backoff();
} else if (!doBackoff) {
const { terminal, refreshToken, connect } = this;
const keyDispose = terminal.onKey(e => {
const event = e.domEvent;
if (event.key === 'Enter') {
keyDispose.dispose();
overlayAddon.showOverlay('Reconnecting...', null);
refreshToken().then(connect);
}
});
overlayAddon.showOverlay('Press ⏎ to Reconnect', null);
}
}

Expand Down

0 comments on commit 9c1e464

Please sign in to comment.