Skip to content

Commit

Permalink
Show retry prompt after 20s
Browse files Browse the repository at this point in the history
  • Loading branch information
whitecrownclown committed Feb 17, 2019
1 parent 0054892 commit 2e9bb30
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {bestFacebookLocaleFor} from 'facebook-locales';
import updateAppMenu from './menu';
import config from './config';
import tray from './tray';
import {sendAction} from './util';
import {sendAction, showRetryDialog} from './util';
import {process as processEmojiUrl} from './emoji';
import './touch-bar'; // eslint-disable-line import/no-unassigned-import

Expand Down Expand Up @@ -289,7 +289,11 @@ function createMainWindow(): BrowserWindow {

// TODO: Reload mainWindow instead as soon as #712 is fixed
if (!(await isOnline())) {
const connectivityTimeout = setTimeout(() => {
showRetryDialog(`It appears that you're offline`);
}, 20000);
await pWaitFor(isOnline, {interval: 1000});
clearTimeout(connectivityTimeout);
app.relaunch();
app.quit();
}
Expand Down
20 changes: 20 additions & 0 deletions source/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,23 @@ export function showRestartDialog(message: string): void {
}
);
}

export function showRetryDialog(message: string): void {
dialog.showMessageBox(
{
message,
detail: `Do you want to retry?`,
buttons: ['Try again', 'Quit'],
defaultId: 0,
cancelId: 1
},
response => {
if (response === 0) {
app.relaunch();
app.quit();
} else {
app.quit();
}
}
);
}

0 comments on commit 2e9bb30

Please sign in to comment.