diff --git a/components/tables/podcast/EpisodesTable.vue b/components/tables/podcast/EpisodesTable.vue index dad3e06c..5603e863 100644 --- a/components/tables/podcast/EpisodesTable.vue +++ b/components/tables/podcast/EpisodesTable.vue @@ -79,9 +79,6 @@ export default { episodesCopy: [], showFiltersModal: false, showSortModal: false, - sortKey: 'publishedAt', - sortDesc: true, - filterKey: 'incomplete', fetchingRSSFeed: false, podcastFeedEpisodes: [], showPodcastEpisodeFeed: false, @@ -223,6 +220,27 @@ export default { if (!this.sortKey) return '' const _sel = this.episodeSortItems.find((i) => i.value === this.sortKey) return _sel?.text || '' + }, + filterKey() { + return this.$store.getters['user/getUserSetting']('podcastEpisodesFilterBy') || 'incomplete' + }, + sortKey: { + get() { + return this.$store.getters['user/getUserSetting']('podcastEpisodesOrderBy') || 'publishedAt' + }, + set(val) { + this.$store.dispatch('user/updateUserSettings', { podcastEpisodesOrderBy: val }) + } + }, + sortDesc: { + get() { + const desc = this.$store.getters['user/getUserSetting']('podcastEpisodesOrderDesc') + if (desc == null) return this.mediaMetadata.type === 'episodic' + return desc + }, + set(val) { + this.$store.dispatch('user/updateUserSettings', { podcastEpisodesOrderDesc: val }) + } } }, methods: { @@ -277,8 +295,8 @@ export default { this.$store.commit('globals/setShowPlaylistsAddCreateModal', true) }, setFilter(filter) { - this.filterKey = filter this.showFiltersModal = false + this.$store.dispatch('user/updateUserSettings', { podcastEpisodesFilterBy: filter }) }, showFilters() { this.showFiltersModal = true @@ -291,7 +309,6 @@ export default { return this.$store.getters['user/getUserMediaProgress'](this.libraryItemId, episode.id) }, init() { - this.sortDesc = this.mediaMetadata.type === 'episodic' this.episodesCopy = this.episodes.map((ep) => { return { ...ep } }) @@ -316,7 +333,7 @@ export default { }, mounted() { if (this.$route.query['episodefilter'] === 'downloaded') { - this.filterKey = 'downloaded' + this.$store.dispatch('user/updateUserSettings', { podcastEpisodesFilterBy: 'downloaded' }) } this.$socket.$on('episode_download_queued', this.episodeDownloadQueued) this.$socket.$on('episode_download_started', this.episodeDownloadStarted) diff --git a/store/user.js b/store/user.js index 5b9951c9..e4765142 100644 --- a/store/user.js +++ b/store/user.js @@ -12,7 +12,10 @@ export const state = () => ({ mobileFilterBy: 'all', playbackRate: 1, collapseSeries: false, - collapseBookSeries: false + collapseBookSeries: false, + podcastEpisodesOrderBy: 'publishedAt', + podcastEpisodesOrderDesc: null, + podcastEpisodesFilterBy: 'incomplete' } }) @@ -45,7 +48,7 @@ export const getters = { return state.user.bookmarks.filter((bm) => bm.libraryItemId === libraryItemId) }, getUserSetting: (state) => (key) => { - return state.settings?.[key] || null + return state.settings?.[key] ?? null }, getUserCanUpdate: (state) => { return !!state.user?.permissions?.update