refactor casting spells on the client side (#9949)

This commit is contained in:
Matteo Pagliazzi
2018-02-04 15:51:17 +01:00
committed by GitHub
parent fdcc69fe4a
commit 20556e2af4
2 changed files with 17 additions and 21 deletions

View File

@@ -188,22 +188,12 @@ export default {
};
},
mounted () {
this.$root.$on('castEnd', (target, type, $event) => {
this.castEnd(target, type, $event);
});
document.addEventListener('keyup', this.handleKeyUp);
// @TODO: should we abstract the drawer state/local store to a library and mixing combo? We use a similar pattern in equipment
const spellDrawerState = getLocalSetting(CONSTANTS.keyConstants.SPELL_DRAWER_STATE);
if (spellDrawerState === CONSTANTS.valueConstants.DRAWER_CLOSED) {
this.$store.state.spellOptions.spellDrawOpen = false;
}
},
beforeDestroy () {
this.$root.$off('castEnd');
document.removeEventListener('keyup', this.handleKeyUp);
},
computed: {
...mapState({user: 'user.data'}),
openStatus () {
@@ -211,10 +201,6 @@ export default {
},
},
methods: {
handleKeyUp (keyEvent) {
if (keyEvent.keyCode !== 27) return;
this.castCancel();
},
drawerToggled (newState) {
this.$store.state.spellOptions.spellDrawOpen = newState;