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:
parent
f5a2206004
commit
d9fc1e81cd
1 changed files with 15 additions and 1 deletions
|
@ -810,6 +810,20 @@ class ZenKeyboardShortcutsVersioner {
|
|||
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) {
|
||||
if (version < 1) {
|
||||
// Migrate from 0 to 1
|
||||
|
@ -950,7 +964,7 @@ var gZenKeyboardShortcutsManager = {
|
|||
if (this.inBrowserView) {
|
||||
const loadedShortcuts = await this._loadSaved();
|
||||
|
||||
this._currentShortcutList = this.versioner.migrateIfNeeded(loadedShortcuts);
|
||||
this._currentShortcutList = this.versioner.fixedKeyboardShortcuts(loadedShortcuts);
|
||||
this._applyShortcuts();
|
||||
|
||||
await this._saveShortcuts();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue