diff options
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/client/SettingClient.ts | 4 | ||||
-rw-r--r-- | src/content/usecases/KeymapUseCase.ts | 21 |
2 files changed, 10 insertions, 15 deletions
diff --git a/src/content/client/SettingClient.ts b/src/content/client/SettingClient.ts index 0850f11..a7cd1ee 100644 --- a/src/content/client/SettingClient.ts +++ b/src/content/client/SettingClient.ts @@ -1,4 +1,4 @@ -import Settings from '../../shared/Settings'; +import Settings, { valueOf } from '../../shared/Settings'; import * as messages from '../../shared/messages'; export default interface SettingClient { @@ -10,6 +10,6 @@ export class SettingClientImpl { let settings = await browser.runtime.sendMessage({ type: messages.SETTINGS_QUERY, }); - return settings as Settings; + return valueOf(settings); } } diff --git a/src/content/usecases/KeymapUseCase.ts b/src/content/usecases/KeymapUseCase.ts index 0f654c8..62cd04c 100644 --- a/src/content/usecases/KeymapUseCase.ts +++ b/src/content/usecases/KeymapUseCase.ts @@ -3,16 +3,16 @@ import KeymapRepository from '../repositories/KeymapRepository'; import SettingRepository from '../repositories/SettingRepository'; import AddonEnabledRepository from '../repositories/AddonEnabledRepository'; import * as operations from '../../shared/operations'; -import { Keymaps } from '../../shared/Settings'; import Key from '../domains/Key'; import KeySequence from '../domains/KeySequence'; +import Keymaps from '../../shared/settings/Keymaps'; type KeymapEntityMap = Map<KeySequence, operations.Operation>; -const reservedKeymaps: Keymaps = { +const reservedKeymaps = Keymaps.fromJSON({ '<Esc>': { type: operations.CANCEL }, '<C-[>': { type: operations.CANCEL }, -}; +}); @injectable() export default class KeymapUseCase { @@ -65,16 +65,11 @@ export default class KeymapUseCase { } private keymapEntityMap(): KeymapEntityMap { - let keymaps = { - ...this.settingRepository.get().keymaps, - ...reservedKeymaps, - }; - let entries = Object.entries(keymaps).map((entry) => { - return [ - KeySequence.fromMapKeys(entry[0]), - entry[1], - ]; - }) as [KeySequence, operations.Operation][]; + let keymaps = this.settingRepository.get().keymaps.combine(reservedKeymaps); + let entries = keymaps.entries().map(entry => [ + KeySequence.fromMapKeys(entry[0]), + entry[1], + ]) as [KeySequence, operations.Operation][]; return new Map<KeySequence, operations.Operation>(entries); } } |