mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-03 01:35:08 +02:00
Fix:Clean user data on server start removing invalid media progress items
This commit is contained in:
parent
9ee6eaade9
commit
ac30a971c5
9 changed files with 107 additions and 70 deletions
|
@ -187,6 +187,11 @@ export default {
|
|||
this.$toast.error('Failed to start scan')
|
||||
})
|
||||
},
|
||||
userUpdated(user) {
|
||||
if (user.seriesHideFromContinueListening && user.seriesHideFromContinueListening.length) {
|
||||
this.removeAllSeriesFromContinueSeries(user.seriesHideFromContinueListening)
|
||||
}
|
||||
},
|
||||
libraryItemAdded(libraryItem) {
|
||||
console.log('libraryItem added', libraryItem)
|
||||
// TODO: Check if libraryItem would be on this shelf
|
||||
|
@ -244,23 +249,16 @@ export default {
|
|||
this.libraryItemUpdated(li)
|
||||
})
|
||||
},
|
||||
seriesUpdated(series) {
|
||||
if (series.hideFromHome) {
|
||||
this.shelves.forEach((shelf) => {
|
||||
if (shelf.type == 'book' && shelf.id == 'continue-series') {
|
||||
// Filter out series books from continue series shelf
|
||||
shelf.entities = shelf.entities.filter((ent) => {
|
||||
if (ent.media.metadata.series && ent.media.metadata.series.id == series.id) return false
|
||||
return true
|
||||
})
|
||||
} else if (shelf.type == 'series') {
|
||||
// Filter out series from series shelf
|
||||
shelf.entities = shelf.entities.filter((ent) => {
|
||||
return ent.id != series.id
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
removeAllSeriesFromContinueSeries(seriesIds) {
|
||||
this.shelves.forEach((shelf) => {
|
||||
if (shelf.type == 'book' && shelf.id == 'continue-series') {
|
||||
// Filter out series books from continue series shelf
|
||||
shelf.entities = shelf.entities.filter((ent) => {
|
||||
if (ent.media.metadata.series && seriesIds.includes(ent.media.metadata.series.id)) return false
|
||||
return true
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
authorUpdated(author) {
|
||||
this.shelves.forEach((shelf) => {
|
||||
|
@ -288,7 +286,7 @@ export default {
|
|||
this.$store.commit('user/addSettingsListener', { id: 'bookshelf', meth: this.settingsUpdated })
|
||||
|
||||
if (this.$root.socket) {
|
||||
this.$root.socket.on('series_updated', this.seriesUpdated)
|
||||
this.$root.socket.on('user_updated', this.userUpdated)
|
||||
this.$root.socket.on('author_updated', this.authorUpdated)
|
||||
this.$root.socket.on('author_removed', this.authorRemoved)
|
||||
this.$root.socket.on('item_updated', this.libraryItemUpdated)
|
||||
|
@ -304,7 +302,7 @@ export default {
|
|||
this.$store.commit('user/removeSettingsListener', 'bookshelf')
|
||||
|
||||
if (this.$root.socket) {
|
||||
this.$root.socket.off('series_updated', this.seriesUpdated)
|
||||
this.$root.socket.off('user_updated', this.userUpdated)
|
||||
this.$root.socket.off('author_updated', this.authorUpdated)
|
||||
this.$root.socket.off('author_removed', this.authorRemoved)
|
||||
this.$root.socket.off('item_updated', this.libraryItemUpdated)
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
<span class="font-mono">{{ numShowing }}</span>
|
||||
</div>
|
||||
<div class="flex-grow" />
|
||||
<ui-btn v-if="seriesHideFromHome" :loading="processingSeriesHideFromHome" color="primary" small class="mr-2" @click="showSeriesOnHome">Show on Home</ui-btn>
|
||||
<ui-btn color="primary" small :loading="processingSeries" class="flex items-center" @click="markSeriesFinished">
|
||||
<div class="h-5 w-5">
|
||||
<svg v-if="isSeriesFinished" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="rgb(63, 181, 68)">
|
||||
|
@ -95,8 +94,7 @@ export default {
|
|||
keywordTimeout: null,
|
||||
processingSeries: false,
|
||||
processingIssues: false,
|
||||
processingAuthors: false,
|
||||
processingSeriesHideFromHome: false
|
||||
processingAuthors: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -152,9 +150,6 @@ export default {
|
|||
seriesName() {
|
||||
return this.selectedSeries ? this.selectedSeries.name : null
|
||||
},
|
||||
seriesHideFromHome() {
|
||||
return this.selectedSeries ? this.selectedSeries.hideFromHome : null
|
||||
},
|
||||
seriesProgress() {
|
||||
return this.selectedSeries ? this.selectedSeries.progress : null
|
||||
},
|
||||
|
@ -176,23 +171,6 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
async showSeriesOnHome() {
|
||||
this.processingSeriesHideFromHome = true
|
||||
const seriesId = this.selectedSeries.id
|
||||
this.$axios
|
||||
.$patch(`/api/series/${seriesId}`, { hideFromHome: false })
|
||||
.then((data) => {
|
||||
console.log('Updated series', data)
|
||||
this.$toast.success('Series updated successfully')
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Failed to update series', error)
|
||||
this.$toast.error('Failed to update series')
|
||||
})
|
||||
.finally(() => {
|
||||
this.processingSeriesHideFromHome = false
|
||||
})
|
||||
},
|
||||
async matchAllAuthors() {
|
||||
this.processingAuthors = true
|
||||
|
||||
|
|
|
@ -411,10 +411,10 @@ export default {
|
|||
text: 'Re-Scan'
|
||||
})
|
||||
}
|
||||
if (this.userIsAdminOrUp && this.series && this.bookMount) {
|
||||
if (this.series && this.bookMount) {
|
||||
items.push({
|
||||
func: 'hideSeriesFromHome',
|
||||
text: 'Hide Series from Home'
|
||||
func: 'hideSeriesFromContinueListening',
|
||||
text: 'Hide Series from Continue Series'
|
||||
})
|
||||
}
|
||||
return items
|
||||
|
@ -595,17 +595,17 @@ export default {
|
|||
// More menu func
|
||||
this.store.commit('showEditModalOnTab', { libraryItem: this.libraryItem, tab: 'match' })
|
||||
},
|
||||
hideSeriesFromHome() {
|
||||
hideSeriesFromContinueListening() {
|
||||
const axios = this.$axios || this.$nuxt.$axios
|
||||
this.processing = true
|
||||
axios
|
||||
.$patch(`/api/series/${this.series.id}`, { hideFromHome: true })
|
||||
.$post(`/api/me/series/${this.series.id}/hide`)
|
||||
.then((data) => {
|
||||
console.log('Series updated', data)
|
||||
console.log('User updated', data)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Failed to hide series from home', error)
|
||||
this.$toast.error('Failed to update series')
|
||||
this.$toast.error('Failed to update user')
|
||||
})
|
||||
.finally(() => {
|
||||
this.processing = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue