Use references in key actions (#204)

This commit is contained in:
József Farkas
2016-12-13 23:09:39 +01:00
committed by GitHub
parent 3380a9d514
commit e48fdea89d
33 changed files with 266 additions and 255 deletions

View File

@@ -58,9 +58,8 @@ export class KeymapTabComponent implements OnInit, OnChanges, Tab {
return false;
}
let switchKeymapAction: SwitchKeymapAction = <SwitchKeymapAction>keyAction;
this.selectedKeymap = this.keymaps
.find((keymap: Keymap) => keymap.abbreviation === switchKeymapAction.keymapAbbreviation);
const switchKeymapAction: SwitchKeymapAction = <SwitchKeymapAction>keyAction;
this.selectedKeymap = switchKeymapAction.keymap;
}
toKeyAction(): SwitchKeymapAction {
@@ -68,8 +67,8 @@ export class KeymapTabComponent implements OnInit, OnChanges, Tab {
throw new Error('KeyAction is not valid. No selected keymap!');
}
let keymapAction = new SwitchKeymapAction();
keymapAction.keymapAbbreviation = this.selectedKeymap.abbreviation;
const keymapAction = new SwitchKeymapAction();
keymapAction.keymap = this.selectedKeymap;
return keymapAction;
}
}

View File

@@ -60,8 +60,8 @@ export class MacroTabComponent implements OnInit, OnChanges, OnDestroy, Tab {
if (!(keyAction instanceof PlayMacroAction)) {
return false;
}
let playMacroAction: PlayMacroAction = <PlayMacroAction>keyAction;
this.selectedMacroIndex = this.macros.findIndex(macro => playMacroAction.macroId === macro.id);
const playMacroAction: PlayMacroAction = <PlayMacroAction>keyAction;
this.selectedMacroIndex = this.macros.findIndex(macro => playMacroAction.macro === macro);
return true;
}
@@ -70,8 +70,8 @@ export class MacroTabComponent implements OnInit, OnChanges, OnDestroy, Tab {
throw new Error('KeyAction is not valid. No selected macro!');
}
let keymapAction = new PlayMacroAction();
keymapAction.macroId = this.macros[this.selectedMacroIndex].id;
const keymapAction = new PlayMacroAction();
keymapAction.macro = this.macros[this.selectedMacroIndex];
return keymapAction;
}