Ensure fallback 'update available' dialog cannot stack

This commit is contained in:
Josh Perez 2020-02-21 15:41:05 -08:00 committed by GitHub
parent 8d9ccd3c0a
commit c347a2761a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 21 deletions

View file

@ -24,7 +24,6 @@ import { hexToBinary, verifySignature } from './signature';
import { markShouldQuit } from '../../app/window_state';
import { Dialogs } from '../types/Dialogs';
let isChecking = false;
const SECOND = 1000;
const MINUTE = SECOND * 60;
const INTERVAL = MINUTE * 30;
@ -60,14 +59,8 @@ async function checkDownloadAndInstall(
locale: LocaleType,
logger: LoggerType
) {
if (isChecking) {
return;
}
logger.info('checkDownloadAndInstall: checking for update...');
try {
isChecking = true;
const result = await checkForUpdates(logger);
if (!result) {
return;
@ -121,8 +114,6 @@ async function checkDownloadAndInstall(
});
} catch (error) {
logger.error('checkDownloadAndInstall: error', getPrintableError(error));
} finally {
isChecking = false;
}
}
@ -358,10 +349,16 @@ export function showReadOnlyDialog(
}, ACK_RENDER_TIMEOUT);
}
let showingReadOnlyDialog = false;
async function showFallbackReadOnlyDialog(
mainWindow: BrowserWindow,
locale: LocaleType
) {
if (showingReadOnlyDialog) {
return;
}
const options = {
type: 'warning',
buttons: [locale.messages.ok.message],
@ -369,5 +366,9 @@ async function showFallbackReadOnlyDialog(
message: locale.i18n('readOnlyVolume', ['Signal.app', '/Applications']),
};
showingReadOnlyDialog = true;
await dialog.showMessageBox(mainWindow, options);
showingReadOnlyDialog = false;
}