From 09376506cd6a82417556fba57c2bcc38a2844458 Mon Sep 17 00:00:00 2001 From: Daniel Andrei Date: Wed, 14 Aug 2019 18:46:53 +0300 Subject: [PATCH] Fix schema validation crash (#1037) * Fix dialogs crash * Add proper config defaults --- source/config.ts | 26 ++++++++++++++++---------- source/ensure-online.ts | 18 +++++++----------- source/util.ts | 18 +++++++----------- 3 files changed, 30 insertions(+), 32 deletions(-) diff --git a/source/config.ts b/source/config.ts index fdfc9981f..26c48d0d2 100644 --- a/source/config.ts +++ b/source/config.ts @@ -30,12 +30,10 @@ const schema: {[key: string]: JSONSchema} = { type: 'object', properties: { width: { - type: 'number', - default: 800 + type: 'number' }, height: { - type: 'number', - default: 600 + type: 'number' }, x: { type: 'number' @@ -43,6 +41,12 @@ const schema: {[key: string]: JSONSchema} = { y: { type: 'number' } + }, + default: { + width: 800, + height: 600, + x: undefined, + y: undefined } }, menuBarMode: { @@ -88,17 +92,19 @@ const schema: {[key: string]: JSONSchema} = { type: 'object', properties: { chatSeen: { - type: 'boolean', - default: false + type: 'boolean' }, typingIndicator: { - type: 'boolean', - default: false + type: 'boolean' }, deliveryReceipt: { - type: 'boolean', - default: false + type: 'boolean' } + }, + default: { + chatSeen: false, + typingIndicator: false, + deliveryReceipt: false } }, emojiStyle: { diff --git a/source/ensure-online.ts b/source/ensure-online.ts index 99be4184a..83f2541a9 100644 --- a/source/ensure-online.ts +++ b/source/ensure-online.ts @@ -3,17 +3,13 @@ import isOnline from 'is-online'; import pWaitFor from 'p-wait-for'; function showWaitDialog(): void { - const buttonIndex = dialog.showMessageBoxSync( - // @ts-ignore - undefined, - { - message: 'You appear to be offline. Caprine requires a working internet connection.', - detail: 'Do you want to wait?', - buttons: ['Wait', 'Quit'], - defaultId: 0, - cancelId: 1 - } - ); + const buttonIndex = dialog.showMessageBoxSync({ + message: 'You appear to be offline. Caprine requires a working internet connection.', + detail: 'Do you want to wait?', + buttons: ['Wait', 'Quit'], + defaultId: 0, + cancelId: 1 + }); if (buttonIndex === 1) { app.quit(); diff --git a/source/util.ts b/source/util.ts index a01a6fed7..5a986c508 100644 --- a/source/util.ts +++ b/source/util.ts @@ -21,17 +21,13 @@ export function sendBackgroundAction(action: string, ...args: unknown[]): void { } export function showRestartDialog(message: string): void { - const buttonIndex = dialog.showMessageBoxSync( - // @ts-ignore - undefined, - { - message, - detail: 'Do you want to restart the app now?', - buttons: ['Restart', 'Ignore'], - defaultId: 0, - cancelId: 1 - } - ); + const buttonIndex = dialog.showMessageBoxSync({ + message, + detail: 'Do you want to restart the app now?', + buttons: ['Restart', 'Ignore'], + defaultId: 0, + cancelId: 1 + }); if (buttonIndex === 0) { app.relaunch();