Skip to content

Commit

Permalink
Cache last restart changed value to auto hide notification bar
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdh committed Aug 10, 2016
1 parent c84e656 commit 67625f1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
41 changes: 25 additions & 16 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ let throttleKeytar = false
const passwordCallbacks = {}

const prefsRestartCallbacks = {}
const prefsRestartLastValue = {}

/**
* Gets the master key for encrypting login credentials from the OS keyring.
Expand Down Expand Up @@ -410,23 +411,31 @@ app.on('ready', () => {
app.quit()
})

ipcMain.on(messages.PREFS_RESTART, () => {
ipcMain.on(messages.PREFS_RESTART, (e, config, value) => {
var message = locale.translation('prefsRestart')

appActions.showMessageBox({
buttons: [locale.translation('yes'), locale.translation('no')],
options: {
persist: false
},
message
})
prefsRestartCallbacks[message] = (buttonIndex, persist) => {
delete prefsRestartCallbacks[message]
if (buttonIndex === 0) {
app.relaunch({args: process.argv.slice(1) + ['--relaunch']})
app.quit()
} else {
appActions.hideMessageBox(message)
if (prefsRestartLastValue[config] !== undefined && prefsRestartLastValue[config] !== value) {
delete prefsRestartLastValue[config]
appActions.hideMessageBox(message)
} else {
appActions.showMessageBox({
buttons: [locale.translation('yes'), locale.translation('no')],
options: {
persist: false
},
message
})
prefsRestartCallbacks[message] = (buttonIndex, persist) => {
delete prefsRestartCallbacks[message]
if (buttonIndex === 0) {
app.relaunch({args: process.argv.slice(1) + ['--relaunch']})
app.quit()
} else {
delete prefsRestartLastValue[config]
appActions.hideMessageBox(message)
}
}
if (prefsRestartLastValue[config] === undefined) {
prefsRestartLastValue[config] = value
}
}
})
Expand Down
4 changes: 2 additions & 2 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class SecurityTab extends ImmutableComponent {
}
onToggleFlash (e) {
aboutActions.setResourceEnabled(flash, e.target.value)
ipc.send(messages.PREFS_RESTART)
ipc.send(messages.PREFS_RESTART, flash, e.target.value)
}
render () {
const lastPassPreferencesUrl = ('chrome-extension://' + extensionIds[passwordManagers.LAST_PASS] + '/tabDialog.html?dialog=preferences&cmd=open')
Expand Down Expand Up @@ -685,7 +685,7 @@ class AboutPreferences extends React.Component {
aboutActions.changeSetting(key, value)
if (key === settings.DO_NOT_TRACK || key === settings.HARDWARE_ACCELERATION_ENABLED ||
key === settings.PDFJS_ENABLED || key === settings.SMOOTH_SCROLL_ENABLED) {
ipc.send(messages.PREFS_RESTART)
ipc.send(messages.PREFS_RESTART, key, value)
}
}

Expand Down

0 comments on commit 67625f1

Please sign in to comment.