Skip to content

Commit

Permalink
bug: edit loading
Browse files Browse the repository at this point in the history
  • Loading branch information
rootkwak528 committed Aug 1, 2021
1 parent d78515b commit 14465d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
1 change: 0 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<!-- loading spinner -->
<div v-if="loading" id="container" class="text-light d-flex flex-column justify-content-center align-items-center">
<div class="spinner-border"></div>
<h1>Loading..</h1>

<div id="loading-message-container">
<div id="loading-message">
Expand Down
24 changes: 3 additions & 21 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,7 @@ export default new Vuex.Store({
},

// tmdb search
setSearchInput ({ commit, dispatch }, searchInput ) {
dispatch('setLoading', true)

setSearchInput ({ commit }, searchInput ) {
const trimmedSearchInput = searchInput.trim()
commit( 'SET_SEARCH_INPUT', trimmedSearchInput )

Expand All @@ -263,8 +261,6 @@ export default new Vuex.Store({
method: 'get',
})
.then( res => {
dispatch('setLoading', false)

const results = ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ]
let idx = 0
res.data.results.forEach(movie => {
Expand All @@ -276,8 +272,6 @@ export default new Vuex.Store({
commit( 'SET_SEARCH_RESULTS', results )
})
.catch( err => {
dispatch('setLoading', false)

console.log(err)
})

Expand Down Expand Up @@ -312,35 +306,27 @@ export default new Vuex.Store({
// commit('RESET_MOVIE_OBJECTS')
// },

async getRecommends ({ commit, dispatch }, movieId) {
dispatch('setLoading', true)

async getRecommends ({ commit }, movieId) {
const url = `https://api.themoviedb.org/3/movie/${movieId}/recommendations?api_key=${API_KEY}&language=ko-KR&page=1`

await axios({
url: url,
method: 'get',
})
.then( res => {
dispatch('setLoading', false)

if (res.data.results) {
commit('SET_MOVIE_RECOMMENDS', res.data.results)
} else {
commit('SET_MOVIE_RECOMMENDS', null)
}
})
.catch( err => {
dispatch('setLoading', false)

console.log(err)
commit('SET_MOVIE_RECOMMENDS', null)
})
},

async getDetail ({ commit, dispatch }, movie ){
dispatch('setLoading', true)

async getDetail ({ commit }, movie ){
const url = `${SERVER_URL}/movies/`

await axios({
Expand All @@ -349,14 +335,10 @@ export default new Vuex.Store({
data: movie,
})
.then( res => {
dispatch('setLoading', false)

console.log('Action getDetail()', res.data)
commit('SET_MOVIE_DETAIL', res.data)
})
.catch( err => {
dispatch('setLoading', false)

console.log( err )
commit('SET_MOVIE_DETAIL', null)
})
Expand Down

0 comments on commit 14465d9

Please sign in to comment.