From ba4e9ab7e3807217253faf2a374998f3d2442a9d Mon Sep 17 00:00:00 2001 From: advplyr Date: Thu, 3 Jul 2025 17:40:02 -0500 Subject: [PATCH] Add explicit library filters --- components/modals/FilterModal.vue | 85 ++++++++++++++++++++----------- store/user.js | 29 ++++++----- strings/en-us.json | 1 + 3 files changed, 74 insertions(+), 41 deletions(-) diff --git a/components/modals/FilterModal.vue b/components/modals/FilterModal.vue index a551a0f4..296db325 100644 --- a/components/modals/FilterModal.vue +++ b/components/modals/FilterModal.vue @@ -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' diff --git a/store/user.js b/store/user.js index 78c2fcfe..f0c23eb7 100644 --- a/store/user.js +++ b/store/user.js @@ -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 }) } -} \ No newline at end of file +} diff --git a/strings/en-us.json b/strings/en-us.json index be1b9a5f..8ee7a956 100644 --- a/strings/en-us.json +++ b/strings/en-us.json @@ -146,6 +146,7 @@ "LabelEndOfChapter": "End of Chapter", "LabelEndTime": "End time", "LabelEpisode": "Episode", + "LabelExplicit": "Explicit", "LabelFeedURL": "Feed URL", "LabelFile": "File", "LabelFileBirthtime": "File Birthtime",