Skip to content

Commit

Permalink
Fix outdated subscription cache clearing code when "Remove All Subscr…
Browse files Browse the repository at this point in the history
…iptions / Profiles" performed (#3817)

* ! Fix outdated subscription cache clearing code when "Remove All Subscriptions / Profiles" performed

* * Use one action to clear cache instead of three

* $ Use early return
  • Loading branch information
PikachuEXE authored Aug 1, 2023
1 parent 0b5107f commit d207571
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 31 deletions.
32 changes: 16 additions & 16 deletions src/renderer/components/privacy-settings/privacy-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,24 @@ export default defineComponent({

this.updateActiveProfile(MAIN_PROFILE_ID)

if (option === 'yes') {
this.profileList.forEach((profile) => {
if (profile._id === MAIN_PROFILE_ID) {
const newProfile = {
_id: MAIN_PROFILE_ID,
name: profile.name,
bgColor: profile.bgColor,
textColor: profile.textColor,
subscriptions: []
}
this.updateProfile(newProfile)
} else {
this.removeProfile(profile._id)
if (option !== 'yes') { return }

this.profileList.forEach((profile) => {
if (profile._id === MAIN_PROFILE_ID) {
const newProfile = {
_id: MAIN_PROFILE_ID,
name: profile.name,
bgColor: profile.bgColor,
textColor: profile.textColor,
subscriptions: []
}
})
this.updateProfile(newProfile)
} else {
this.removeProfile(profile._id)
}
})

this.clearSubscriptionsCache()
}
this.clearSubscriptionsCache()
},

...mapActions([
Expand Down
24 changes: 9 additions & 15 deletions src/renderer/store/modules/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,27 @@ const getters = {

getLiveCacheByChannel: (state) => (channelId) => {
return state.liveCache[channelId]
}
},
}

const actions = {
clearSubscriptionVideosCache: ({ commit }) => {
commit('clearVideoCache')
},

updateSubscriptionVideosCacheByChannel: ({ commit }, payload) => {
commit('updateVideoCacheByChannel', payload)
},

clearSubscriptionShortsCache: ({ commit }) => {
commit('clearShortsCache')
},

updateSubscriptionShortsCacheByChannel: ({ commit }, payload) => {
commit('updateShortsCacheByChannel', payload)
},

clearSubscriptionLiveCache: ({ commit }) => {
commit('clearLiveCache')
},

updateSubscriptionLiveCacheByChannel: ({ commit }, payload) => {
commit('updateLiveCacheByChannel', payload)
}
},

clearSubscriptionsCache: ({ commit }, payload) => {
commit('clearVideoCache', payload)
commit('clearShortsCache', payload)
commit('clearLiveCache', payload)
},
}

const mutations = {
Expand Down Expand Up @@ -91,7 +85,7 @@ const mutations = {
},
clearLiveCache(state) {
state.liveCache = {}
}
},
}

export default {
Expand Down

0 comments on commit d207571

Please sign in to comment.