fix user options by making loader recursive (#318)

This commit is contained in:
end-4
2024-03-12 15:44:54 +07:00
parent 0fd23f69f0
commit f3d235c9a3
2 changed files with 12 additions and 11 deletions
@@ -72,7 +72,7 @@ let configOptions = {
'': "image-missing",
}
},
'keybinds': {
'keybinds': {
// Format: Mod1+Mod2+key. CaSe SeNsItIvE!
// Modifiers: Shift Ctrl Alt Hyper Meta
// See https://docs.gtk.org/gdk3/index.html#constants for the other keys (they are listed as KEY_key)
@@ -94,11 +94,17 @@ let configOptions = {
},
}
// Load user's options
Object.entries(userOverrides).forEach((override) => {
const [key, value] = override;
configOptions[key] = value;
});
// Override defaults with user's options
function overrideConfigRecursive(userOverrides, configOptions = {}) {
for (const [key, value] of Object.entries(userOverrides)) {
if (typeof value === 'object') {
overrideConfigRecursive(value, configOptions[key]);
} else {
configOptions[key] = value;
}
}
}
overrideConfigRecursive(userOverrides, configOptions);
globalThis['userOptions'] = configOptions;
export default configOptions;
-5
View File
@@ -5,12 +5,7 @@ const userConfigOptions = {
// Here's an example
'keybinds': {
'sidebar': {
'apis': {
'nextTab': "Page_Down",
'prevTab': "Page_Up",
},
'pin': "Ctrl+p",
'cycleTab': "Ctrl+Tab",
'nextTab': "Ctrl+Page_Down",
'prevTab': "Ctrl+Page_Up",
},