From 598d970b939bee8f871ca1793b80f016ab48e766 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Wed, 27 Mar 2024 01:37:19 +0100 Subject: [PATCH] Create empty subscriptions cache objects directly instead of cloning (#4814) --- src/renderer/store/modules/subscriptions.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/renderer/store/modules/subscriptions.js b/src/renderer/store/modules/subscriptions.js index c85168423..2ce05c7b6 100644 --- a/src/renderer/store/modules/subscriptions.js +++ b/src/renderer/store/modules/subscriptions.js @@ -1,9 +1,3 @@ -import { deepCopy } from '../../helpers/utils' - -const defaultCacheEntryValueForForOneChannel = { - videos: null, -} - const state = { videoCache: {}, liveCache: {}, @@ -77,7 +71,7 @@ const actions = { const mutations = { updateVideoCacheByChannel(state, { channelId, videos }) { const existingObject = state.videoCache[channelId] - const newObject = existingObject != null ? existingObject : deepCopy(defaultCacheEntryValueForForOneChannel) + const newObject = existingObject ?? { videos: null } if (videos != null) { newObject.videos = videos } state.videoCache[channelId] = newObject }, @@ -86,7 +80,7 @@ const mutations = { }, updateShortsCacheByChannel(state, { channelId, videos }) { const existingObject = state.shortsCache[channelId] - const newObject = existingObject != null ? existingObject : deepCopy(defaultCacheEntryValueForForOneChannel) + const newObject = existingObject ?? { videos: null } if (videos != null) { newObject.videos = videos } state.shortsCache[channelId] = newObject }, @@ -120,7 +114,7 @@ const mutations = { }, updateLiveCacheByChannel(state, { channelId, videos }) { const existingObject = state.liveCache[channelId] - const newObject = existingObject != null ? existingObject : deepCopy(defaultCacheEntryValueForForOneChannel) + const newObject = existingObject ?? { videos: null } if (videos != null) { newObject.videos = videos } state.liveCache[channelId] = newObject }, @@ -129,7 +123,7 @@ const mutations = { }, updatePostsCacheByChannel(state, { channelId, posts }) { const existingObject = state.postsCache[channelId] - const newObject = existingObject != null ? existingObject : deepCopy(defaultCacheEntryValueForForOneChannel) + const newObject = existingObject ?? { posts: null } if (posts != null) { newObject.posts = posts } state.postsCache[channelId] = newObject },