mirror of
https://github.com/sudoxnym/audiobookshelf-atv.git
synced 2026-07-13 23:42:21 +00:00
Add explicit library filters
This commit is contained in:
parent
1b4fa5e44a
commit
ba4e9ab7e3
3 changed files with 74 additions and 41 deletions
|
|
@ -54,8 +54,39 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
sublist: null,
|
||||
bookItems: [
|
||||
sublist: null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
show(newVal) {
|
||||
if (!newVal) {
|
||||
if (this.sublist && !this.selectedItemSublist) this.sublist = null
|
||||
if (!this.sublist && this.selectedItemSublist) this.sublist = this.selectedItemSublist
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
show: {
|
||||
get() {
|
||||
return this.value
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('input', val)
|
||||
}
|
||||
},
|
||||
selected: {
|
||||
get() {
|
||||
return this.filterBy
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('update:filterBy', val)
|
||||
}
|
||||
},
|
||||
userCanAccessExplicitContent() {
|
||||
return this.$store.getters['user/getUserCanAccessExplicitContent']
|
||||
},
|
||||
bookItems() {
|
||||
const items = [
|
||||
{
|
||||
text: this.$strings.LabelAll,
|
||||
value: 'all'
|
||||
|
|
@ -110,8 +141,20 @@ export default {
|
|||
value: 'feed-open',
|
||||
sublist: false
|
||||
}
|
||||
],
|
||||
podcastItems: [
|
||||
]
|
||||
|
||||
if (this.userCanAccessExplicitContent) {
|
||||
items.push({
|
||||
text: this.$strings.LabelExplicit,
|
||||
value: 'explicit',
|
||||
sublist: false
|
||||
})
|
||||
}
|
||||
|
||||
return items
|
||||
},
|
||||
podcastItems() {
|
||||
const items = [
|
||||
{
|
||||
text: this.$strings.LabelAll,
|
||||
value: 'all'
|
||||
|
|
@ -132,32 +175,16 @@ export default {
|
|||
sublist: false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
show(newVal) {
|
||||
if (!newVal) {
|
||||
if (this.sublist && !this.selectedItemSublist) this.sublist = null
|
||||
if (!this.sublist && this.selectedItemSublist) this.sublist = this.selectedItemSublist
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
show: {
|
||||
get() {
|
||||
return this.value
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('input', val)
|
||||
}
|
||||
},
|
||||
selected: {
|
||||
get() {
|
||||
return this.filterBy
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('update:filterBy', val)
|
||||
|
||||
if (this.userCanAccessExplicitContent) {
|
||||
items.push({
|
||||
text: this.$strings.LabelExplicit,
|
||||
value: 'explicit',
|
||||
sublist: false
|
||||
})
|
||||
}
|
||||
|
||||
return items
|
||||
},
|
||||
isPodcast() {
|
||||
return this.$store.getters['libraries/getCurrentLibraryMediaType'] === 'podcast'
|
||||
|
|
|
|||
|
|
@ -31,16 +31,18 @@ export const getters = {
|
|||
getCustomHeaders: (state) => {
|
||||
return state.serverConnectionConfig?.customHeaders || null
|
||||
},
|
||||
getUserMediaProgress: (state) => (libraryItemId, episodeId = null) => {
|
||||
if (!state.user?.mediaProgress) return null
|
||||
return state.user.mediaProgress.find(li => {
|
||||
if (episodeId && li.episodeId !== episodeId) return false
|
||||
return li.libraryItemId == libraryItemId
|
||||
})
|
||||
},
|
||||
getUserMediaProgress:
|
||||
(state) =>
|
||||
(libraryItemId, episodeId = null) => {
|
||||
if (!state.user?.mediaProgress) return null
|
||||
return state.user.mediaProgress.find((li) => {
|
||||
if (episodeId && li.episodeId !== episodeId) return false
|
||||
return li.libraryItemId == libraryItemId
|
||||
})
|
||||
},
|
||||
getUserBookmarksForItem: (state) => (libraryItemId) => {
|
||||
if (!state?.user?.bookmarks) return []
|
||||
return state.user.bookmarks.filter(bm => bm.libraryItemId === libraryItemId)
|
||||
return state.user.bookmarks.filter((bm) => bm.libraryItemId === libraryItemId)
|
||||
},
|
||||
getUserSetting: (state) => (key) => {
|
||||
return state.settings?.[key] || null
|
||||
|
|
@ -53,6 +55,9 @@ export const getters = {
|
|||
},
|
||||
getUserCanDownload: (state) => {
|
||||
return !!state.user?.permissions?.download
|
||||
},
|
||||
getUserCanAccessExplicitContent: (state) => {
|
||||
return !!state.user?.permissions?.accessExplicitContent
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -145,11 +150,11 @@ export const mutations = {
|
|||
},
|
||||
removeMediaProgress(state, id) {
|
||||
if (!state.user) return
|
||||
state.user.mediaProgress = state.user.mediaProgress.filter(mp => mp.id != id)
|
||||
state.user.mediaProgress = state.user.mediaProgress.filter((mp) => mp.id != id)
|
||||
},
|
||||
updateUserMediaProgress(state, data) {
|
||||
if (!data || !state.user) return
|
||||
const mediaProgressIndex = state.user.mediaProgress.findIndex(mp => mp.id === data.id)
|
||||
const mediaProgressIndex = state.user.mediaProgress.findIndex((mp) => mp.id === data.id)
|
||||
if (mediaProgressIndex >= 0) {
|
||||
state.user.mediaProgress.splice(mediaProgressIndex, 1, data)
|
||||
} else {
|
||||
|
|
@ -174,9 +179,9 @@ export const mutations = {
|
|||
},
|
||||
deleteBookmark(state, { libraryItemId, time }) {
|
||||
if (!state.user?.bookmarks) return
|
||||
state.user.bookmarks = state.user.bookmarks.filter(bm => {
|
||||
state.user.bookmarks = state.user.bookmarks.filter((bm) => {
|
||||
if (bm.libraryItemId === libraryItemId && bm.time === time) return false
|
||||
return true
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@
|
|||
"LabelEndOfChapter": "End of Chapter",
|
||||
"LabelEndTime": "End time",
|
||||
"LabelEpisode": "Episode",
|
||||
"LabelExplicit": "Explicit",
|
||||
"LabelFeedURL": "Feed URL",
|
||||
"LabelFile": "File",
|
||||
"LabelFileBirthtime": "File Birthtime",
|
||||
|
|
|
|||
Loading…
Reference in a new issue