[go: up one dir, main page]

Skip to content

Commit

Permalink
Added restart confirmation dialog on settings update. Fixes #65
Browse files Browse the repository at this point in the history
  • Loading branch information
klaudiosinani committed Apr 25, 2018
1 parent d8d9691 commit 9a0d220
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,35 @@ function confirmLogOut() {
defaultId: 0, // Make `Log Out` the default action button
cancelId: 1
});
return response === 0;
return (response === 0);
};
// Check whether the log-out button was pressed
if (logOut()) {
activate('log-out');
}
}

function requestAppRestart() {
const restart = () => {
// Display restart confirmation dialog on settings update
const response = dialog.showMessageBox({
icon: path.join(__dirname, 'static/Icon.png'),
title: 'Restart Required',
message: 'Restart Tusk to Activate New Settings',
detail: 'Would you like to restart now?',
buttons: ['Restart', 'Dismiss'],
defaultId: 0, // Make `Restart` the default action button
cancelId: 1
});
return (response === 0);
};
// Check whether the restart button was pressed
if (restart()) {
app.quit();
app.relaunch();
}
}

const helpSubmenu = [{
label: `View License`,
click() {
Expand All @@ -192,35 +213,31 @@ const helpSubmenu = [{
checked: (config.get('updateCheckPeriod') === '2h'),
click() {
config.set('updateCheckPeriod', '2h');
app.relaunch();
app.quit();
requestAppRestart();
}
}, {
label: 'Once Every 6 Hours',
type: 'checkbox',
checked: (config.get('updateCheckPeriod') === '6h'),
click() {
config.set('updateCheckPeriod', '6h');
app.relaunch();
app.quit();
requestAppRestart();
}
}, {
label: 'Once Every 12 Hours',
type: 'checkbox',
checked: (config.get('updateCheckPeriod') === '12h'),
click() {
config.set('updateCheckPeriod', '12h');
app.relaunch();
app.quit();
requestAppRestart();
}
}, {
label: 'Once a Day',
type: 'checkbox',
checked: (config.get('updateCheckPeriod') === '24h'),
click() {
config.set('updateCheckPeriod', '24h');
app.relaunch();
app.quit();
requestAppRestart();
}
}]
}, {
Expand Down Expand Up @@ -426,8 +443,7 @@ const darwinTpl = [{
checked: config.get('useGlobalShortcuts'),
click(item) {
config.set('useGlobalShortcuts', item.checked);
app.relaunch();
app.quit();
requestAppRestart();
}
}, {
type: 'separator'
Expand Down Expand Up @@ -973,8 +989,7 @@ const otherTpl = [{
checked: config.get('useGlobalShortcuts'),
click(item) {
config.set('useGlobalShortcuts', item.checked);
app.relaunch();
app.quit();
requestAppRestart();
}
}, {
type: 'separator'
Expand All @@ -983,16 +998,14 @@ const otherTpl = [{
visible: !config.get('useYinxiang'),
click() {
config.set('useYinxiang', true);
app.relaunch();
app.quit();
requestAppRestart();
}
}, {
label: 'Switch to Evernote',
visible: config.get('useYinxiang'),
click() {
config.set('useYinxiang', false);
app.relaunch();
app.quit();
requestAppRestart();
}
}, {
type: 'separator'
Expand Down Expand Up @@ -1139,8 +1152,7 @@ const otherTpl = [{
checked: config.get('hideTray'),
click(item) {
config.set('hideTray', item.checked);
app.relaunch();
app.quit();
requestAppRestart();
}
}, {
type: 'separator'
Expand Down

0 comments on commit 9a0d220

Please sign in to comment.