Skip to content

Commit

Permalink
Update subscription view to be able to load videos from video cache p…
Browse files Browse the repository at this point in the history
…er channel (#3668)

* Changes from PR #3673

* * Update subscription view to be able to load videos from video cache again

* * Update subscription view to be able to load videos from video cache per channel

* * Remove meaningless argument `allowUseOfChannelCache`

* $ Remove unused imports

---------

Co-authored-by: petaded <[email protected]>
  • Loading branch information
PikachuEXE and petaded authored Jul 2, 2023
1 parent bcf21f6 commit 242c93e
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ export default defineComponent({
},
hideUpcomingPremieres: function () {
return this.$store.getters.getHideUpcomingPremieres
}
},
methods: {
onVisibilityChanged: function (visible) {
this.visible = visible
},

/**
* Show or Hide results in the list
*
Expand All @@ -70,10 +64,9 @@ export default defineComponent({
// hide livestreams
return false
}

if (this.hideUpcomingPremieres &&
// Observed for premieres in Local API Channels.
(data.durationText === 'PREMIERE' ||
(data.premiereDate != null ||
// viewCount is our only method of detecting premieres in RSS
// data without sending an additional request.
// If we ever get a better flag, use it here instead.
Expand All @@ -98,6 +91,11 @@ export default defineComponent({
}
return true
}
},
methods: {
onVisibilityChanged: function (visible) {
this.visible = visible
}

}
})
10 changes: 2 additions & 8 deletions src/renderer/components/privacy-settings/privacy-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,7 @@ export default defineComponent({
}
})

this.updateAllSubscriptionsList([])
this.updateProfileSubscriptions({
activeProfile: MAIN_PROFILE_ID,
videoList: [],
errorChannels: []
})
this.clearSubscriptionsCache()
}
},

Expand All @@ -129,8 +124,7 @@ export default defineComponent({
'updateProfile',
'removeProfile',
'updateActiveProfile',
'updateAllSubscriptionsList',
'updateProfileSubscriptions'
'clearSubscriptionsCache',
])
}
})
46 changes: 24 additions & 22 deletions src/renderer/store/modules/subscriptions.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
import { MAIN_PROFILE_ID } from '../../../constants'
const defaultCacheEntryValueForForOneChannel = {
videos: null,
}

function deepCopy(obj) {
return JSON.parse(JSON.stringify(obj))
}

const state = {
allSubscriptionsList: [],
profileSubscriptions: {
activeProfile: MAIN_PROFILE_ID,
videoList: [],
errorChannels: []
}
subscriptionsCachePerChannel: {},
}

const getters = {
getAllSubscriptionsList: () => {
return state.allSubscriptionsList
getSubscriptionsCacheEntriesForOneChannel: (state) => (channelId) => {
return state.subscriptionsCachePerChannel[channelId]
},
getProfileSubscriptions: () => {
return state.profileSubscriptions
}
}

const actions = {
updateAllSubscriptionsList ({ commit }, subscriptions) {
commit('setAllSubscriptionsList', subscriptions)
clearSubscriptionsCache: ({ commit }) => {
commit('clearSubscriptionsCachePerChannel')
},

updateSubscriptionsCacheForOneChannel: ({ commit }, payload) => {
commit('updateSubscriptionsCacheForOneChannel', payload)
},
updateProfileSubscriptions ({ commit }, subscriptions) {
commit('setProfileSubscriptions', subscriptions)
}
}

const mutations = {
setAllSubscriptionsList (state, allSubscriptionsList) {
state.allSubscriptionsList = allSubscriptionsList
updateSubscriptionsCacheForOneChannel(state, { channelId, videos }) {
const existingObject = state.subscriptionsCachePerChannel[channelId]
const newObject = existingObject != null ? existingObject : deepCopy(defaultCacheEntryValueForForOneChannel)
if (videos != null) { newObject.videos = videos }
state.subscriptionsCachePerChannel[channelId] = newObject
},
clearSubscriptionsCachePerChannel(state) {
state.subscriptionsCachePerChannel = {}
},
setProfileSubscriptions (state, profileSubscriptions) {
state.profileSubscriptions = profileSubscriptions
}
}

export default {
Expand Down
Loading

0 comments on commit 242c93e

Please sign in to comment.