-
Notifications
You must be signed in to change notification settings - Fork 865
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ux): move preferences to menubar
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
- Loading branch information
Showing
16 changed files
with
340 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,22 @@ | ||
const { ipcMain } = require('electron') | ||
const os = require('os') | ||
const store = require('./common/store') | ||
const logger = require('./common/logger') | ||
|
||
module.exports = function ({ webui }, settingsOption, activate) { | ||
ipcMain.on('config.toggle', async (_, opt) => { | ||
if (opt !== settingsOption) { | ||
return | ||
} | ||
|
||
module.exports = function (settingsOption, activate) { | ||
ipcMain.on(`toggle_${settingsOption}`, async () => { | ||
const oldValue = store.get(settingsOption, null) | ||
const newValue = !oldValue | ||
let success = false | ||
|
||
if (await activate(newValue, oldValue)) { | ||
if (await activate({ newValue, oldValue, feedback: true })) { | ||
store.set(settingsOption, newValue) | ||
success = true | ||
|
||
const action = newValue ? 'enabled' : 'disabled' | ||
logger.info(`[${settingsOption}] ${action}`) | ||
} | ||
|
||
webui.webContents.send('config.changed', { | ||
config: store.store, | ||
changed: settingsOption, | ||
platform: os.platform(), | ||
success | ||
}) | ||
// We always emit the event so any handlers for it can act upon | ||
// the current configuration, whether it was successfully | ||
// updated or not. | ||
ipcMain.emit('configUpdated') | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.