mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-28 17:49:06 +01:00
Add:Button on series books page to re-add series to continue listening #1159
This commit is contained in:
parent
c5d66989a6
commit
3316394f5c
@ -39,6 +39,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<span class="pl-2"> {{ $strings.LabelMarkSeries }} {{ isSeriesFinished ? $strings.LabelNotFinished : $strings.LabelFinished }}</span>
|
<span class="pl-2"> {{ $strings.LabelMarkSeries }} {{ isSeriesFinished ? $strings.LabelNotFinished : $strings.LabelFinished }}</span>
|
||||||
</ui-btn>
|
</ui-btn>
|
||||||
|
<ui-btn v-if="isSeriesRemovedFromContinueListening" small :loading="processingSeries" @click="reAddSeriesToContinueListening" class="hidden md:block ml-2"> Re-Add Series to Continue Listening </ui-btn>
|
||||||
</template>
|
</template>
|
||||||
<!-- library & collections page -->
|
<!-- library & collections page -->
|
||||||
<template v-else-if="page !== 'search' && page !== 'podcast-search' && page !== 'recent-episodes' && !isHome">
|
<template v-else-if="page !== 'search' && page !== 'podcast-search' && page !== 'recent-episodes' && !isHome">
|
||||||
@ -156,6 +157,9 @@ export default {
|
|||||||
if (this.isCollectionsPage) return this.$strings.LabelCollections
|
if (this.isCollectionsPage) return this.$strings.LabelCollections
|
||||||
return ''
|
return ''
|
||||||
},
|
},
|
||||||
|
seriesId() {
|
||||||
|
return this.selectedSeries ? this.selectedSeries.id : null
|
||||||
|
},
|
||||||
seriesName() {
|
seriesName() {
|
||||||
return this.selectedSeries ? this.selectedSeries.name : null
|
return this.selectedSeries ? this.selectedSeries.name : null
|
||||||
},
|
},
|
||||||
@ -169,6 +173,10 @@ export default {
|
|||||||
isSeriesFinished() {
|
isSeriesFinished() {
|
||||||
return this.seriesProgress && !!this.seriesProgress.isFinished
|
return this.seriesProgress && !!this.seriesProgress.isFinished
|
||||||
},
|
},
|
||||||
|
isSeriesRemovedFromContinueListening() {
|
||||||
|
if (!this.seriesId) return false
|
||||||
|
return this.$store.getters['user/getIsSeriesRemovedFromContinueListening'](this.seriesId)
|
||||||
|
},
|
||||||
filterBy() {
|
filterBy() {
|
||||||
return this.$store.getters['user/getUserSetting']('filterBy')
|
return this.$store.getters['user/getUserSetting']('filterBy')
|
||||||
},
|
},
|
||||||
@ -201,6 +209,21 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
reAddSeriesToContinueListening() {
|
||||||
|
this.processingSeries = true
|
||||||
|
this.$axios
|
||||||
|
.$get(`/api/me/series/${this.seriesId}/readd-to-continue-listening`)
|
||||||
|
.then(() => {
|
||||||
|
this.$toast.success('Series re-added to continue listening')
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Failed to re-add series to continue listening', error)
|
||||||
|
this.$toast.error('Failed to re-add series to continue listening')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.processingSeries = false
|
||||||
|
})
|
||||||
|
},
|
||||||
async matchAllAuthors() {
|
async matchAllAuthors() {
|
||||||
this.processingAuthors = true
|
this.processingAuthors = true
|
||||||
|
|
||||||
@ -238,12 +261,13 @@ export default {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
this.$toast.success('Removed library items with issues')
|
this.$toast.success('Removed library items with issues')
|
||||||
this.$router.push(`/library/${this.currentLibraryId}/bookshelf`)
|
this.$router.push(`/library/${this.currentLibraryId}/bookshelf`)
|
||||||
this.processingIssues = false
|
|
||||||
this.$store.dispatch('libraries/fetch', this.currentLibraryId)
|
this.$store.dispatch('libraries/fetch', this.currentLibraryId)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Failed to remove library items with issues', error)
|
console.error('Failed to remove library items with issues', error)
|
||||||
this.$toast.error('Failed to remove library items with issues')
|
this.$toast.error('Failed to remove library items with issues')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
this.processingIssues = false
|
this.processingIssues = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,10 @@ export const getters = {
|
|||||||
if (!state.user) return false
|
if (!state.user) return false
|
||||||
if (getters.getUserCanAccessAllLibraries) return true
|
if (getters.getUserCanAccessAllLibraries) return true
|
||||||
return getters.getLibrariesAccessible.includes(libraryId)
|
return getters.getLibrariesAccessible.includes(libraryId)
|
||||||
|
},
|
||||||
|
getIsSeriesRemovedFromContinueListening: (state) => (seriesId) => {
|
||||||
|
if (!state.user || !state.user.seriesHideFromContinueListening || !state.user.seriesHideFromContinueListening.length) return false
|
||||||
|
return state.user.seriesHideFromContinueListening.includes(seriesId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,6 +293,22 @@ class MeController {
|
|||||||
res.json(req.user.toJSONForBrowser())
|
res.json(req.user.toJSONForBrowser())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GET: api/me/series/:id/readd-to-continue-listening
|
||||||
|
async readdSeriesFromContinueListening(req, res) {
|
||||||
|
const series = this.db.series.find(se => se.id === req.params.id)
|
||||||
|
if (!series) {
|
||||||
|
Logger.error(`[MeController] readdSeriesFromContinueListening: Series ${req.params.id} not found`)
|
||||||
|
return res.sendStatus(404)
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasUpdated = req.user.removeSeriesFromHideFromContinueListening(req.params.id)
|
||||||
|
if (hasUpdated) {
|
||||||
|
await this.db.updateEntity('user', req.user)
|
||||||
|
this.clientEmitter(req.user.id, 'user_updated', req.user.toJSONForBrowser())
|
||||||
|
}
|
||||||
|
res.json(req.user.toJSONForBrowser())
|
||||||
|
}
|
||||||
|
|
||||||
// GET: api/me/progress/:id/remove-from-continue-listening
|
// GET: api/me/progress/:id/remove-from-continue-listening
|
||||||
async removeItemFromContinueListening(req, res) {
|
async removeItemFromContinueListening(req, res) {
|
||||||
const hasUpdated = req.user.removeProgressFromContinueListening(req.params.id)
|
const hasUpdated = req.user.removeProgressFromContinueListening(req.params.id)
|
||||||
|
@ -434,6 +434,12 @@ class User {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeSeriesFromHideFromContinueListening(seriesId) {
|
||||||
|
if (!this.seriesHideFromContinueListening.includes(seriesId)) return false
|
||||||
|
this.seriesHideFromContinueListening = this.seriesHideFromContinueListening.filter(sid => sid !== seriesId)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
removeProgressFromContinueListening(progressId) {
|
removeProgressFromContinueListening(progressId) {
|
||||||
const progress = this.mediaProgress.find(mp => mp.id === progressId)
|
const progress = this.mediaProgress.find(mp => mp.id === progressId)
|
||||||
if (!progress) return false
|
if (!progress) return false
|
||||||
|
@ -156,6 +156,7 @@ class ApiRouter {
|
|||||||
this.router.post('/me/sync-local-progress', MeController.syncLocalMediaProgress.bind(this))
|
this.router.post('/me/sync-local-progress', MeController.syncLocalMediaProgress.bind(this))
|
||||||
this.router.get('/me/items-in-progress', MeController.getAllLibraryItemsInProgress.bind(this))
|
this.router.get('/me/items-in-progress', MeController.getAllLibraryItemsInProgress.bind(this))
|
||||||
this.router.get('/me/series/:id/remove-from-continue-listening', MeController.removeSeriesFromContinueListening.bind(this))
|
this.router.get('/me/series/:id/remove-from-continue-listening', MeController.removeSeriesFromContinueListening.bind(this))
|
||||||
|
this.router.get('/me/series/:id/readd-to-continue-listening', MeController.readdSeriesFromContinueListening.bind(this))
|
||||||
|
|
||||||
//
|
//
|
||||||
// Backup Routes
|
// Backup Routes
|
||||||
|
Loading…
Reference in New Issue
Block a user