From 207ed6b21f92b7c630e3bf799d1633a6cc0a7d8d Mon Sep 17 00:00:00 2001 From: Marcin Cichocki Date: Sat, 15 Oct 2022 18:37:20 +0200 Subject: [PATCH] chore: add migration for new keybinds --- src/electron/main/store/store.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/electron/main/store/store.ts b/src/electron/main/store/store.ts index 551e3eda..c991a260 100644 --- a/src/electron/main/store/store.ts +++ b/src/electron/main/store/store.ts @@ -56,6 +56,32 @@ export class Store { store.set(option.id, ''); } }, + '>=2.8.0': (store) => { + const newKeyBinds = options.filter( + (o) => + o.id === 'keyBindWithPriority6' || o.id === 'keyBindWithPriority7' + ); + const values = newKeyBinds.map(({ defaultValue }) => + normalize(defaultValue as string) + ); + const conflict = [ + 'keyBind', + 'keyBindWithPriority1', + 'keyBindWithPriority2', + 'keyBindWithPriority3', + 'keyBindWithPriority4', + 'keyBindWithPriority5', + 'keyBindAnalyze', + ] + .map((k) => normalize(store.get(k))) + .some((v) => values.includes(v)); + + if (conflict) { + newKeyBinds.forEach((option) => { + store.set(option.id, ''); + }); + } + }, }, });