Skip to content

Commit

Permalink
Feat: Add action to delete all chapters #46, #97
Browse files Browse the repository at this point in the history
  • Loading branch information
Letty committed Dec 23, 2019
1 parent 88b5315 commit 4a3147b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion store/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,28 @@ export const actions = {
throw Error(e)
}
},
deleteAudioChapters: async function deleteAudioChapters(
{ dispatch, getters },
data
) {
data.token = this.$apolloHelpers.getToken()
await Promise.all(
getters.activeAudioChapters.map(async chapter => {
const query = {
chapter: chapter,
audio_id: data.audio_id
}
await restAudioChapters.deleteChapter(query).then(data => {
return data && data.data
})
})
)
},
getAudioChapters: async function getAudioChapters({ commit }, data) {
console.log('Getting Audio Chapters', data)
data.token = this.$apolloHelpers.getToken()
try {
const res = await restAudioChapters.getChapters(data).then(data => {
console.log('return data: ', data)
return data && data.data
})
await commit('set_active_audio_chapters', res)
Expand Down

0 comments on commit 4a3147b

Please sign in to comment.