Move all status/alert dialogs into the Left Pane
This commit is contained in:
parent
101070bf42
commit
18fd44f504
50 changed files with 1298 additions and 607 deletions
|
@ -18,9 +18,10 @@ import { v4 as getGuid } from 'uuid';
|
|||
import pify from 'pify';
|
||||
import mkdirp from 'mkdirp';
|
||||
import rimraf from 'rimraf';
|
||||
import { app, BrowserWindow, dialog } from 'electron';
|
||||
import { app, BrowserWindow, dialog, ipcMain } from 'electron';
|
||||
|
||||
import { getTempPath } from '../../app/attachments';
|
||||
import { Dialogs } from '../types/Dialogs';
|
||||
|
||||
// @ts-ignore
|
||||
import * as packageJson from '../../package.json';
|
||||
|
@ -49,6 +50,8 @@ const mkdirpPromise = pify(mkdirp);
|
|||
const rimrafPromise = pify(rimraf);
|
||||
const { platform } = process;
|
||||
|
||||
export const ACK_RENDER_TIMEOUT = 10000;
|
||||
|
||||
export async function checkForUpdates(
|
||||
logger: LoggerType
|
||||
): Promise<{
|
||||
|
@ -141,10 +144,10 @@ export async function downloadUpdate(
|
|||
}
|
||||
}
|
||||
|
||||
export async function showUpdateDialog(
|
||||
async function showFallbackUpdateDialog(
|
||||
mainWindow: BrowserWindow,
|
||||
messages: MessagesType
|
||||
): Promise<boolean> {
|
||||
) {
|
||||
const RESTART_BUTTON = 0;
|
||||
const LATER_BUTTON = 1;
|
||||
const options = {
|
||||
|
@ -165,10 +168,32 @@ export async function showUpdateDialog(
|
|||
return response === RESTART_BUTTON;
|
||||
}
|
||||
|
||||
export async function showCannotUpdateDialog(
|
||||
export function showUpdateDialog(
|
||||
mainWindow: BrowserWindow,
|
||||
messages: MessagesType,
|
||||
performUpdateCallback: () => void
|
||||
): void {
|
||||
let ack = false;
|
||||
|
||||
ipcMain.once('start-update', performUpdateCallback);
|
||||
|
||||
ipcMain.once('show-update-dialog-ack', () => {
|
||||
ack = true;
|
||||
});
|
||||
|
||||
mainWindow.webContents.send('show-update-dialog', Dialogs.Update);
|
||||
|
||||
setTimeout(async () => {
|
||||
if (!ack) {
|
||||
await showFallbackUpdateDialog(mainWindow, messages);
|
||||
}
|
||||
}, ACK_RENDER_TIMEOUT);
|
||||
}
|
||||
|
||||
async function showFallbackCannotUpdateDialog(
|
||||
mainWindow: BrowserWindow,
|
||||
messages: MessagesType
|
||||
): Promise<any> {
|
||||
) {
|
||||
const options = {
|
||||
type: 'error',
|
||||
buttons: [messages.ok.message],
|
||||
|
@ -179,6 +204,25 @@ export async function showCannotUpdateDialog(
|
|||
await dialog.showMessageBox(mainWindow, options);
|
||||
}
|
||||
|
||||
export function showCannotUpdateDialog(
|
||||
mainWindow: BrowserWindow,
|
||||
messages: MessagesType
|
||||
): void {
|
||||
let ack = false;
|
||||
|
||||
ipcMain.once('show-update-dialog-ack', () => {
|
||||
ack = true;
|
||||
});
|
||||
|
||||
mainWindow.webContents.send('show-update-dialog', Dialogs.Cannot_Update);
|
||||
|
||||
setTimeout(async () => {
|
||||
if (!ack) {
|
||||
await showFallbackCannotUpdateDialog(mainWindow, messages);
|
||||
}
|
||||
}, ACK_RENDER_TIMEOUT);
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
|
||||
export function getUpdateCheckUrl(): string {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue