From 32c3f5d07885031c132076095d03f68d98502353 Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Thu, 27 Jul 2023 08:57:59 +0800 Subject: [PATCH 1/3] ! Fix outdated subscription cache clearing code when "Remove All Subscriptions / Profiles" performed --- .../components/privacy-settings/privacy-settings.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/privacy-settings/privacy-settings.js b/src/renderer/components/privacy-settings/privacy-settings.js index 03d65a5f88d6f..6718e5e99b900 100644 --- a/src/renderer/components/privacy-settings/privacy-settings.js +++ b/src/renderer/components/privacy-settings/privacy-settings.js @@ -110,7 +110,9 @@ export default defineComponent({ } }) - this.clearSubscriptionsCache() + this.clearSubscriptionVideosCache() + this.clearSubscriptionShortsCache() + this.clearSubscriptionLiveCache() } }, @@ -124,7 +126,9 @@ export default defineComponent({ 'updateProfile', 'removeProfile', 'updateActiveProfile', - 'clearSubscriptionsCache', + 'clearSubscriptionVideosCache', + 'clearSubscriptionShortsCache', + 'clearSubscriptionLiveCache', ]) } }) From 7629c36500e7420c73d4bd8a5b31bfd778960de9 Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Thu, 27 Jul 2023 14:11:04 +0800 Subject: [PATCH 2/3] * Use one action to clear cache instead of three --- .../privacy-settings/privacy-settings.js | 8 ++----- src/renderer/store/modules/subscriptions.js | 24 +++++++------------ 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/renderer/components/privacy-settings/privacy-settings.js b/src/renderer/components/privacy-settings/privacy-settings.js index 6718e5e99b900..03d65a5f88d6f 100644 --- a/src/renderer/components/privacy-settings/privacy-settings.js +++ b/src/renderer/components/privacy-settings/privacy-settings.js @@ -110,9 +110,7 @@ export default defineComponent({ } }) - this.clearSubscriptionVideosCache() - this.clearSubscriptionShortsCache() - this.clearSubscriptionLiveCache() + this.clearSubscriptionsCache() } }, @@ -126,9 +124,7 @@ export default defineComponent({ 'updateProfile', 'removeProfile', 'updateActiveProfile', - 'clearSubscriptionVideosCache', - 'clearSubscriptionShortsCache', - 'clearSubscriptionLiveCache', + 'clearSubscriptionsCache', ]) } }) diff --git a/src/renderer/store/modules/subscriptions.js b/src/renderer/store/modules/subscriptions.js index ba86c3b54cd31..e9b0c4e1efc71 100644 --- a/src/renderer/store/modules/subscriptions.js +++ b/src/renderer/store/modules/subscriptions.js @@ -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 = { @@ -91,7 +85,7 @@ const mutations = { }, clearLiveCache(state) { state.liveCache = {} - } + }, } export default { From 6b1dc22dd5098bc23e5b5ae3838ca9fb96255209 Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Thu, 27 Jul 2023 14:12:26 +0800 Subject: [PATCH 3/3] $ Use early return --- .../privacy-settings/privacy-settings.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/renderer/components/privacy-settings/privacy-settings.js b/src/renderer/components/privacy-settings/privacy-settings.js index 03d65a5f88d6f..0b541e0a532d7 100644 --- a/src/renderer/components/privacy-settings/privacy-settings.js +++ b/src/renderer/components/privacy-settings/privacy-settings.js @@ -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([