add Promise to FETCH_CHARACTER action, add getCharacter getter to store, fix Skeleton.vue animated position bricking

This commit is contained in:
Xevion
2020-09-17 13:59:54 -05:00
parent ec25ce6571
commit 46bea4af4d
2 changed files with 18 additions and 9 deletions

View File

@@ -26,14 +26,14 @@
@-webkit-keyframes SkeletonLoading { @-webkit-keyframes SkeletonLoading {
0% { 0% {
background-position: 0 0; background-position: -200px 0;
} }
100% { 100% {
background-position: calc(200px + 100%) 0; background-position: calc(200px + 100%) 0;
} }
} }
@keyframes SkeletonLoading { @keyframes SkeletonLoa,ding {
0% { 0% {
background-position: -200px 0; background-position: -200px 0;
} }
@@ -51,8 +51,7 @@ span {
export default { export default {
props: { props: {
inner_style: { inner_style: {
type: String, type: Object
default: ''
}, },
inner_class: { inner_class: {
type: String, type: String,

View File

@@ -118,11 +118,18 @@ export default new Vuex.Store({
}) })
}, },
[types.FETCH_CHARACTER]({commit}, character_id) { [types.FETCH_CHARACTER]({commit}, character_id) {
const path = `${process.env.VUE_APP_API_URL}/api/character/${character_id}/`; return new Promise((resolve, reject) => {
axios.get(path) const path = `${process.env.VUE_APP_API_URL}/api/character/${character_id}/`;
.then((res) => { axios.get(path)
commit(types.MERGE_CHARACTER, {id: character_id, characterData: res.data}) .then((res) => {
}) commit(types.MERGE_CHARACTER, {id: character_id, characterData: res.data})
resolve();
})
.catch((error) => {
reject();
console.error(error);
})
})
} }
}, },
getters: { getters: {
@@ -146,5 +153,8 @@ export default new Vuex.Store({
isValidEpisode: (state, getters) => (season, episode = 1) => { isValidEpisode: (state, getters) => (season, episode = 1) => {
return season >= 1 && season <= 9 && episode >= 1 && episode <= getters.getEpisodeCount(season) return season >= 1 && season <= 9 && episode >= 1 && episode <= getters.getEpisodeCount(season)
}, },
getCharacter: (state) => (character_id) => {
return state.characters[character_id];
}
} }
}); });