1
0
Fork 1
mirror of https://github.com/zen-browser/desktop.git synced 2025-07-10 13:35:29 +02:00

Implement default keyboard shortcuts filling and migration handling

This commit is contained in:
mr. M 2025-02-04 19:26:04 +01:00
parent f5a2206004
commit d9fc1e81cd
No known key found for this signature in database
GPG key ID: CBD57A2AEDBDA1FB

View file

@ -810,6 +810,20 @@ class ZenKeyboardShortcutsVersioner {
return this.migrateIfNeeded(data); return this.migrateIfNeeded(data);
} }
fillDefaultIfNotPresent(data) {
for (let shortcut of ZenKeyboardShortcutsLoader.zenGetDefaultShortcuts()) {
// If it has an ID and we dont find it in the data, we add it
if (shortcut.getID() && !data.find((s) => s.getID() == shortcut.getID())) {
data.push(shortcut);
}
}
return data;
}
fixedKeyboardShortcuts(data) {
return this.fillDefaultIfNotPresent(this.migrateIfNeeded(data));
}
migrate(data, version) { migrate(data, version) {
if (version < 1) { if (version < 1) {
// Migrate from 0 to 1 // Migrate from 0 to 1
@ -950,7 +964,7 @@ var gZenKeyboardShortcutsManager = {
if (this.inBrowserView) { if (this.inBrowserView) {
const loadedShortcuts = await this._loadSaved(); const loadedShortcuts = await this._loadSaved();
this._currentShortcutList = this.versioner.migrateIfNeeded(loadedShortcuts); this._currentShortcutList = this.versioner.fixedKeyboardShortcuts(loadedShortcuts);
this._applyShortcuts(); this._applyShortcuts();
await this._saveShortcuts(); await this._saveShortcuts();