Skip to content

Commit

Permalink
Fix schema validation crash (#1037)
Browse files Browse the repository at this point in the history
* Fix dialogs crash
* Add proper config defaults
  • Loading branch information
whitecrownclown authored and CvX committed Aug 14, 2019
1 parent ccf0ab2 commit 0937650
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 32 deletions.
26 changes: 16 additions & 10 deletions source/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,23 @@ 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'
},
y: {
type: 'number'
}
},
default: {
width: 800,
height: 600,
x: undefined,
y: undefined
}
},
menuBarMode: {
Expand Down Expand Up @@ -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: {
Expand Down
18 changes: 7 additions & 11 deletions source/ensure-online.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
18 changes: 7 additions & 11 deletions source/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 0937650

Please sign in to comment.