Now moves entry to seen lists when entirely watched

This commit is contained in:
Kylart 2019-09-19 14:10:04 +02:00
parent aa40c27e9e
commit 870872424c
2 changed files with 35 additions and 12 deletions

View File

@ -1,15 +1,6 @@
import { mapActions, mapMutations } from 'vuex'
export default {
computed: {
parsedName () {
const parts = this.videoTitle.split(' - ')
return {
name: parts[0],
ep: parts[1]
}
}
},
beforeDestroy () {
const { name: refName, ep: refEp } = this.parsedName
const { autoTracking } = this.$store.state.config.config
@ -25,7 +16,25 @@ export default {
providersAutoTracking.some(Boolean) && this.trackProviders(refName, refEp, providersAutoTracking)
},
computed: {
parsedName () {
const parts = this.videoTitle.split(' - ')
return {
name: parts[0],
ep: parts[1]
}
}
},
methods: {
...mapActions('watchLists', {
localMove: 'move',
localAdd: 'add'
}),
...mapMutations({
tellUser: 'setInfoSnackbar'
}),
trackLocal (refName, refEp) {
// Finding entries with the same name
const lists = this.$store.state.watchLists.lists
@ -48,12 +57,20 @@ export default {
if (isRewatch) return
// Updating progress accordingly
this.$store.dispatch('watchLists/add', {
this.localAdd({
...entry,
progress: +refEp
})
this.$log(`Updated user local progress for ${refName}.`)
// If the entry is fully watched, we should move it to seen
if (entry.nbEp && +refEp === +entry.nbEp) {
this.$log(`Moving ${entry.name} to \`seen\` list as it reached maximum known episode.`)
this.tellUser(`${entry.name} completed. Niiice!`)
this.localMove({ entry, target: 'seen' })
}
})
},
trackProviders (refName, refEp, providers) {

View File

@ -16,6 +16,12 @@ export default {
delete (store, entry) {
ipcRenderer.send(eventsList.localLists.update.main, { type: entry.list, data: entry, isDelete: true })
},
move ({ dispatch }, { entry, target = null }) {
dispatch('delete', entry)
entry.list = target
dispatch('add', entry)
},
info (store, entries) {
ipcRenderer.send(eventsList.localLists.info.main, entries)
},