diff --git a/src/renderer/components/SubscriptionsLive.vue b/src/renderer/components/SubscriptionsLive.vue index 4bea31baf8386..76ad79ac023fa 100644 --- a/src/renderer/components/SubscriptionsLive.vue +++ b/src/renderer/components/SubscriptionsLive.vue @@ -59,6 +59,8 @@ const fetchSubscriptionsAutomatically = computed(() => store.getters.getFetchSub const activeSubscriptionList = computed(() => store.getters.getActiveProfile.subscriptions) +const activeProfileId = computed(() => store.getters.getActiveProfile._id) + const cacheEntriesForAllActiveProfileChannels = computed(() => { const liveCache = store.getters.getLiveCache const entries = [] @@ -140,22 +142,25 @@ function loadVideosFromRemoteFirstPerWindowSometimes() { alreadyLoadedRemotely = true loadVideosForSubscriptionsFromRemote() - store.commit('setSubscriptionForLiveStreamsFirstAutoFetchRun') + store.commit('setSubscriptionForLiveStreamsFirstAutoFetchRun', activeProfileId.value) } function loadVideosFromCacheSometimes() { // Can only load reliably when cache ready if (!subscriptionCacheReady.value) { return } - // This method is called on view visible - if (videoCacheForAllActiveProfileChannelsPresent.value) { - loadVideosFromCacheForAllActiveProfileChannels() + // Check if this profile needs to be auto-fetched for the first time + if (fetchSubscriptionsAutomatically.value && !store.getters.getSubscriptionForLiveStreamsFirstAutoFetchRun) { + // `isLoading.value = false` is called inside `loadVideosForSubscriptionsFromRemote` when needed + alreadyLoadedRemotely = true + loadVideosForSubscriptionsFromRemote() + store.commit('setSubscriptionForLiveStreamsFirstAutoFetchRun', activeProfileId.value) return } - if (fetchSubscriptionsAutomatically.value) { - // `isLoading.value = false` is called inside `loadVideosForSubscriptionsFromRemote` when needed - loadVideosForSubscriptionsFromRemote() + // This method is called on view visible + if (videoCacheForAllActiveProfileChannelsPresent.value) { + loadVideosFromCacheForAllActiveProfileChannels() return } diff --git a/src/renderer/components/SubscriptionsPosts.vue b/src/renderer/components/SubscriptionsPosts.vue index 761d5c0a4636d..0490ed78ae502 100644 --- a/src/renderer/components/SubscriptionsPosts.vue +++ b/src/renderer/components/SubscriptionsPosts.vue @@ -49,6 +49,8 @@ const fetchSubscriptionsAutomatically = computed(() => store.getters.getFetchSub const activeSubscriptionList = computed(() => store.getters.getActiveProfile.subscriptions) +const activeProfileId = computed(() => store.getters.getActiveProfile._id) + const cacheEntriesForAllActiveProfileChannels = computed(() => { const postsCache = store.getters.getPostsCache const entries = [] @@ -130,22 +132,25 @@ function loadPostsFromRemoteFirstPerWindowSometimes() { alreadyLoadedRemotely = true loadPostsForSubscriptionsFromRemote() - store.commit('setSubscriptionForPostsFirstAutoFetchRun') + store.commit('setSubscriptionForPostsFirstAutoFetchRun', activeProfileId.value) } function loadPostsFromCacheSometimes() { // Can only load reliably when cache ready if (!subscriptionCacheReady.value) { return } - // This method is called on view visible - if (postCacheForAllActiveProfileChannelsPresent.value) { - loadPostsFromCacheForAllActiveProfileChannels() + // Check if this profile needs to be auto-fetched for the first time + if (fetchSubscriptionsAutomatically.value && !store.getters.getSubscriptionForPostsFirstAutoFetchRun) { + // `isLoading.value = false` is called inside `loadPostsForSubscriptionsFromRemote` when needed + alreadyLoadedRemotely = true + loadPostsForSubscriptionsFromRemote() + store.commit('setSubscriptionForPostsFirstAutoFetchRun', activeProfileId.value) return } - if (fetchSubscriptionsAutomatically.value) { - // `isLoading.value = false` is called inside `loadPostsForSubscriptionsFromRemote` when needed - loadPostsForSubscriptionsFromRemote() + // This method is called on view visible + if (postCacheForAllActiveProfileChannelsPresent.value) { + loadPostsFromCacheForAllActiveProfileChannels() return } diff --git a/src/renderer/components/SubscriptionsShorts.vue b/src/renderer/components/SubscriptionsShorts.vue index b31403273e7f4..8a4f5c828e84f 100644 --- a/src/renderer/components/SubscriptionsShorts.vue +++ b/src/renderer/components/SubscriptionsShorts.vue @@ -55,6 +55,8 @@ const fetchSubscriptionsAutomatically = computed(() => store.getters.getFetchSub const activeSubscriptionList = computed(() => store.getters.getActiveProfile.subscriptions) +const activeProfileId = computed(() => store.getters.getActiveProfile._id) + const cacheEntriesForAllActiveProfileChannels = computed(() => { const shortsCache = store.getters.getShortsCache const entries = [] @@ -135,22 +137,25 @@ function loadVideosFromRemoteFirstPerWindowSometimes() { alreadyLoadedRemotely = true loadVideosForSubscriptionsFromRemote() - store.commit('setSubscriptionForShortsFirstAutoFetchRun') + store.commit('setSubscriptionForShortsFirstAutoFetchRun', activeProfileId.value) } function loadVideosFromCacheSometimes() { // Can only load reliably when cache ready if (!subscriptionCacheReady.value) { return } - // This method is called on view visible - if (videoCacheForAllActiveProfileChannelsPresent.value) { - loadVideosFromCacheForAllActiveProfileChannels() + // Check if this profile needs to be auto-fetched for the first time + if (fetchSubscriptionsAutomatically.value && !store.getters.getSubscriptionForShortsFirstAutoFetchRun) { + // `isLoading.value = false` is called inside `loadVideosForSubscriptionsFromRemote` when needed + alreadyLoadedRemotely = true + loadVideosForSubscriptionsFromRemote() + store.commit('setSubscriptionForShortsFirstAutoFetchRun', activeProfileId.value) return } - if (fetchSubscriptionsAutomatically.value) { - // `isLoading.value = false` is called inside `loadVideosForSubscriptionsFromRemote` when needed - loadVideosForSubscriptionsFromRemote() + // This method is called on view visible + if (videoCacheForAllActiveProfileChannelsPresent.value) { + loadVideosFromCacheForAllActiveProfileChannels() return } diff --git a/src/renderer/components/SubscriptionsVideos.vue b/src/renderer/components/SubscriptionsVideos.vue index 049a1741a07fd..184dbf498c6ab 100644 --- a/src/renderer/components/SubscriptionsVideos.vue +++ b/src/renderer/components/SubscriptionsVideos.vue @@ -59,6 +59,8 @@ const fetchSubscriptionsAutomatically = computed(() => store.getters.getFetchSub const activeSubscriptionList = computed(() => store.getters.getActiveProfile.subscriptions) +const activeProfileId = computed(() => store.getters.getActiveProfile._id) + const cacheEntriesForAllActiveProfileChannels = computed(() => { const videoCache = store.getters.getVideoCache const entries = [] @@ -139,22 +141,25 @@ function loadVideosFromRemoteFirstPerWindowSometimes() { alreadyLoadedRemotely = true loadVideosForSubscriptionsFromRemote() - store.commit('setSubscriptionForVideosFirstAutoFetchRun') + store.commit('setSubscriptionForVideosFirstAutoFetchRun', activeProfileId.value) } function loadVideosFromCacheSometimes() { // Can only load reliably when cache ready if (!subscriptionCacheReady.value) { return } - // This method is called on view visible - if (videoCacheForAllActiveProfileChannelsPresent.value) { - loadVideosFromCacheForAllActiveProfileChannels() + // Check if this profile needs to be auto-fetched for the first time + if (fetchSubscriptionsAutomatically.value && !store.getters.getSubscriptionForVideosFirstAutoFetchRun) { + // `isLoading.value = false` is called inside `loadVideosForSubscriptionsFromRemote` when needed + alreadyLoadedRemotely = true + loadVideosForSubscriptionsFromRemote() + store.commit('setSubscriptionForVideosFirstAutoFetchRun', activeProfileId.value) return } - if (fetchSubscriptionsAutomatically.value) { - // `isLoading.value = false` is called inside `loadVideosForSubscriptionsFromRemote` when needed - loadVideosForSubscriptionsFromRemote() + // This method is called on view visible + if (videoCacheForAllActiveProfileChannelsPresent.value) { + loadVideosFromCacheForAllActiveProfileChannels() return } diff --git a/src/renderer/store/modules/utils.js b/src/renderer/store/modules/utils.js index 23030154c9cfd..c1807f307f6ff 100644 --- a/src/renderer/store/modules/utils.js +++ b/src/renderer/store/modules/utils.js @@ -49,10 +49,10 @@ const state = { podcasts: '' }, subscriptionFirstAutoFetchRunData: { - videos: false, - liveStreams: false, - shorts: false, - posts: false, + videos: new Set(), + liveStreams: new Set(), + shorts: new Set(), + posts: new Set(), }, appTitle: '', openPrompts: new Set() @@ -159,17 +159,21 @@ const getters = { return state.lastPopularRefreshTimestamp }, - getSubscriptionForVideosFirstAutoFetchRun(state) { - return state.subscriptionFirstAutoFetchRunData.videos === true + getSubscriptionForVideosFirstAutoFetchRun: (state, getters, rootState, rootGetters) => { + const activeProfileId = rootGetters.getActiveProfile._id + return state.subscriptionFirstAutoFetchRunData.videos.has(activeProfileId) }, - getSubscriptionForLiveStreamsFirstAutoFetchRun (state) { - return state.subscriptionFirstAutoFetchRunData.liveStreams === true + getSubscriptionForLiveStreamsFirstAutoFetchRun: (state, getters, rootState, rootGetters) => { + const activeProfileId = rootGetters.getActiveProfile._id + return state.subscriptionFirstAutoFetchRunData.liveStreams.has(activeProfileId) }, - getSubscriptionForShortsFirstAutoFetchRun (state) { - return state.subscriptionFirstAutoFetchRunData.shorts === true + getSubscriptionForShortsFirstAutoFetchRun: (state, getters, rootState, rootGetters) => { + const activeProfileId = rootGetters.getActiveProfile._id + return state.subscriptionFirstAutoFetchRunData.shorts.has(activeProfileId) }, - getSubscriptionForPostsFirstAutoFetchRun (state) { - return state.subscriptionFirstAutoFetchRunData.posts === true + getSubscriptionForPostsFirstAutoFetchRun: (state, getters, rootState, rootGetters) => { + const activeProfileId = rootGetters.getActiveProfile._id + return state.subscriptionFirstAutoFetchRunData.posts.has(activeProfileId) }, getAppTitle (state) { return state.appTitle @@ -787,17 +791,17 @@ const mutations = { state.openPrompts.delete(id) }, - setSubscriptionForVideosFirstAutoFetchRun (state) { - state.subscriptionFirstAutoFetchRunData.videos = true + setSubscriptionForVideosFirstAutoFetchRun (state, profileId) { + state.subscriptionFirstAutoFetchRunData.videos.add(profileId) }, - setSubscriptionForLiveStreamsFirstAutoFetchRun (state) { - state.subscriptionFirstAutoFetchRunData.liveStreams = true + setSubscriptionForLiveStreamsFirstAutoFetchRun (state, profileId) { + state.subscriptionFirstAutoFetchRunData.liveStreams.add(profileId) }, - setSubscriptionForShortsFirstAutoFetchRun (state) { - state.subscriptionFirstAutoFetchRunData.shorts = true + setSubscriptionForShortsFirstAutoFetchRun (state, profileId) { + state.subscriptionFirstAutoFetchRunData.shorts.add(profileId) }, - setSubscriptionForPostsFirstAutoFetchRun (state) { - state.subscriptionFirstAutoFetchRunData.posts = true + setSubscriptionForPostsFirstAutoFetchRun (state, profileId) { + state.subscriptionFirstAutoFetchRunData.posts.add(profileId) } }