From 46bea4af4da38df9eee255cf3e5ef367725fb0b8 Mon Sep 17 00:00:00 2001 From: Xevion Date: Thu, 17 Sep 2020 13:59:54 -0500 Subject: [PATCH] add Promise to FETCH_CHARACTER action, add getCharacter getter to store, fix Skeleton.vue animated position bricking --- client/src/components/Skeleton.vue | 7 +++---- client/src/store.js | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/client/src/components/Skeleton.vue b/client/src/components/Skeleton.vue index b72ab2b..244a047 100644 --- a/client/src/components/Skeleton.vue +++ b/client/src/components/Skeleton.vue @@ -26,14 +26,14 @@ @-webkit-keyframes SkeletonLoading { 0% { - background-position: 0 0; + background-position: -200px 0; } 100% { background-position: calc(200px + 100%) 0; } } -@keyframes SkeletonLoading { +@keyframes SkeletonLoa,ding { 0% { background-position: -200px 0; } @@ -51,8 +51,7 @@ span { export default { props: { inner_style: { - type: String, - default: '' + type: Object }, inner_class: { type: String, diff --git a/client/src/store.js b/client/src/store.js index 78b7e5a..301270c 100644 --- a/client/src/store.js +++ b/client/src/store.js @@ -118,11 +118,18 @@ export default new Vuex.Store({ }) }, [types.FETCH_CHARACTER]({commit}, character_id) { - const path = `${process.env.VUE_APP_API_URL}/api/character/${character_id}/`; - axios.get(path) - .then((res) => { - commit(types.MERGE_CHARACTER, {id: character_id, characterData: res.data}) - }) + return new Promise((resolve, reject) => { + const path = `${process.env.VUE_APP_API_URL}/api/character/${character_id}/`; + axios.get(path) + .then((res) => { + commit(types.MERGE_CHARACTER, {id: character_id, characterData: res.data}) + resolve(); + }) + .catch((error) => { + reject(); + console.error(error); + }) + }) } }, getters: { @@ -146,5 +153,8 @@ export default new Vuex.Store({ isValidEpisode: (state, getters) => (season, episode = 1) => { return season >= 1 && season <= 9 && episode >= 1 && episode <= getters.getEpisodeCount(season) }, + getCharacter: (state) => (character_id) => { + return state.characters[character_id]; + } } });