From a8a0106f2c8d96dd0ababb992e490bb879e2c7db Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Sat, 1 Jun 2024 16:03:22 +0200 Subject: [PATCH] Consolidate clear subscriptions cache into one mutation (#5202) --- src/renderer/store/modules/subscriptions.js | 24 +++++++-------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/renderer/store/modules/subscriptions.js b/src/renderer/store/modules/subscriptions.js index f98f7881b7978..a2abb5f91be55 100644 --- a/src/renderer/store/modules/subscriptions.js +++ b/src/renderer/store/modules/subscriptions.js @@ -60,11 +60,8 @@ const actions = { commit('updatePostsCacheByChannel', payload) }, - clearSubscriptionsCache: ({ commit }, payload) => { - commit('clearVideoCache', payload) - commit('clearShortsCache', payload) - commit('clearLiveCache', payload) - commit('clearPostsCache', payload) + clearSubscriptionsCache: ({ commit }) => { + commit('clearCaches') }, } @@ -76,9 +73,6 @@ const mutations = { newObject.timestamp = timestamp state.videoCache[channelId] = newObject }, - clearVideoCache(state) { - state.videoCache = {} - }, updateShortsCacheByChannel(state, { channelId, videos, timestamp = new Date() }) { const existingObject = state.shortsCache[channelId] const newObject = existingObject ?? { videos: null } @@ -111,9 +105,6 @@ const mutations = { }) } }, - clearShortsCache(state) { - state.shortsCache = {} - }, updateLiveCacheByChannel(state, { channelId, videos, timestamp = new Date() }) { const existingObject = state.liveCache[channelId] const newObject = existingObject ?? { videos: null } @@ -121,9 +112,6 @@ const mutations = { newObject.timestamp = timestamp state.liveCache[channelId] = newObject }, - clearLiveCache(state) { - state.liveCache = {} - }, updatePostsCacheByChannel(state, { channelId, posts, timestamp = new Date() }) { const existingObject = state.postsCache[channelId] const newObject = existingObject ?? { posts: null } @@ -131,9 +119,13 @@ const mutations = { newObject.timestamp = timestamp state.postsCache[channelId] = newObject }, - clearPostsCache(state) { + + clearCaches(state) { + state.videoCache = {} + state.shortsCache = {} + state.liveCache = {} state.postsCache = {} - }, + } } export default {