Skip to content

Commit

Permalink
🐛 Fix: shortkey disabled failure
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #534
  • Loading branch information
Molunerfinn committed Jul 12, 2020
1 parent f40a1bb commit 4f0809e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/main/apis/app/shortKey/shortKeyHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ class ShortKeyHandler {
const commands = db.get('settings.shortKey') as IShortKeyConfigs
Object.keys(commands)
.filter(item => item.includes('picgo:'))
.map(command => {
.forEach(command => {
const config = commands[command]
globalShortcut.register(config.key, () => {
this.handler(command)
})
// if disabled, don't register #534
if (config.enable) {
globalShortcut.register(config.key, () => {
this.handler(command)
})
}
})
}
private initPluginsShortKey () {
Expand All @@ -46,7 +49,10 @@ class ShortKeyHandler {
const command = `${item}:${cmd.name}`
if (db.has(`settings.shortKey[${command}]`)) {
const commandConfig = db.get(`settings.shortKey.${command}`) as IShortKeyConfig
this.registerShortKey(commandConfig, command, cmd.handle, false)
// if disabled, don't register #534
if (commandConfig.enable) {
this.registerShortKey(commandConfig, command, cmd.handle, false)
}
} else {
this.registerShortKey(cmd, command, cmd.handle, true)
}
Expand All @@ -65,6 +71,8 @@ class ShortKeyHandler {
} else {
logger.warn(`${command} do not provide a key to bind`)
}
// if the configfile already had this command
// then writeFlag -> false
if (writeFlag) {
picgo.saveConfig({
[`settings.shortKey.${command}`]: {
Expand Down

0 comments on commit 4f0809e

Please sign in to comment.