mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 20:01:47 +00:00
use store migration
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
const { globalShortcut } = require("electron");
|
||||
const electronLocalshortcut = require("electron-localshortcut");
|
||||
const { setOptions } = require("../../config/plugins");
|
||||
|
||||
const getSongControls = require("../../providers/song-controls");
|
||||
|
||||
@ -20,8 +19,6 @@ function registerShortcuts(win, options) {
|
||||
const songControls = getSongControls(win);
|
||||
const { playPause, next, previous, search } = songControls;
|
||||
|
||||
updateOptions(options);
|
||||
|
||||
if (options.overrideMediaKeys) {
|
||||
_registerGlobalShortcut(win.webContents, "MediaPlayPause", playPause);
|
||||
_registerGlobalShortcut(win.webContents, "MediaNextTrack", next);
|
||||
@ -59,26 +56,4 @@ function registerShortcuts(win, options) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Update options to new format if they are still an array (old format) */
|
||||
function updateOptions(options) {
|
||||
let updated = false;
|
||||
for (const optionType of ["global", "local"]) {
|
||||
if (Array.isArray(options[optionType])) {
|
||||
const updatedOptions = {};
|
||||
for (const optionObject of options[optionType]) {
|
||||
if (optionObject.action && optionObject.shortcut) {
|
||||
updatedOptions[optionObject.action] = optionObject.shortcut;
|
||||
}
|
||||
}
|
||||
|
||||
options[optionType] = updatedOptions;
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
setOptions("shortcuts", options);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = registerShortcuts;
|
||||
|
||||
Reference in New Issue
Block a user