From dced1d691ceafea37c1fa14300c27376c661cad4 Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Mon, 29 Jun 2026 15:13:08 +0800 Subject: [PATCH] * Use batched fetching instead of forcing RSS with sub count > 125 --- src/renderer/components/SubscriptionsLive.vue | 32 +++++++++++++------ .../components/SubscriptionsPosts.vue | 18 +++++++++-- .../components/SubscriptionsVideos.vue | 32 +++++++++++++------ .../views/Subscriptions/Subscriptions.vue | 7 +--- 4 files changed, 61 insertions(+), 28 deletions(-) diff --git a/src/renderer/components/SubscriptionsLive.vue b/src/renderer/components/SubscriptionsLive.vue index 7edb39fb74411..4a363292a75c6 100644 --- a/src/renderer/components/SubscriptionsLive.vue +++ b/src/renderer/components/SubscriptionsLive.vue @@ -185,14 +185,7 @@ async function loadVideosForSubscriptionsFromRemote() { let channelCount = 0 isLoading.value = true - let useRss = useRssFeeds.value - if (channelsToLoadFromRemote.length >= 125 && !useRss) { - showToast( - t('Subscriptions["This profile has a large number of subscriptions. Forcing RSS to avoid rate limiting"]'), - 10000 - ) - useRss = true - } + const useRss = useRssFeeds.value store.commit('setShowProgressBar', true) store.commit('setProgressBarPercentage', 0) @@ -200,8 +193,9 @@ async function loadVideosForSubscriptionsFromRemote() { errorChannels.value = [] const subscriptionUpdates = [] + const videoListFromRemote = [] - const videoListFromRemote = (await Promise.all(channelsToLoadFromRemote.map(async (channel) => { + const processChannel = async (channel) => { let videos, name, thumbnailUrl if (!process.env.SUPPORTS_LOCAL_API || backendPreference.value === 'invidious') { @@ -238,7 +232,25 @@ async function loadVideosForSubscriptionsFromRemote() { } return videos ?? [] - }))).flat() + } + + if (useRss) { + const results = await Promise.all(channelsToLoadFromRemote.map(processChannel)) + videoListFromRemote.push(...results.flat()) + } else { + const CHUNK_SIZE = 80 + const CHUNK_DELAY_MS = 2000 + + for (let i = 0; i < channelsToLoadFromRemote.length; i += CHUNK_SIZE) { + if (i > 0) { + await new Promise(resolve => setTimeout(resolve, CHUNK_DELAY_MS)) + } + + const chunk = channelsToLoadFromRemote.slice(i, i + CHUNK_SIZE) + const chunkResults = await Promise.all(chunk.map(processChannel)) + videoListFromRemote.push(...chunkResults.flat()) + } + } videoList.value = updateVideoListAfterProcessing(videoListFromRemote) isLoading.value = false diff --git a/src/renderer/components/SubscriptionsPosts.vue b/src/renderer/components/SubscriptionsPosts.vue index 9b4c0f8b85fcd..5e96295dd8e3c 100644 --- a/src/renderer/components/SubscriptionsPosts.vue +++ b/src/renderer/components/SubscriptionsPosts.vue @@ -190,8 +190,9 @@ async function loadPostsForSubscriptionsFromRemote() { errorChannels.value = [] const subscriptionUpdates = [] + const postListFromRemote = [] - const postListFromRemote = (await Promise.all(channelsToLoadFromRemote.map(async (channel) => { + const processChannel = async (channel) => { let posts if (!process.env.SUPPORTS_LOCAL_API || backendPreference.value === 'invidious') { posts = await getChannelPostsInvidious(channel) @@ -231,7 +232,20 @@ async function loadPostsForSubscriptionsFromRemote() { posts = posts.filter(post => !forbiddenTitles.value.some(text => post.author.toLowerCase().includes(text))) return posts - }))).flat() + } + + const CHUNK_SIZE = 80 + const CHUNK_DELAY_MS = 2000 + + for (let i = 0; i < channelsToLoadFromRemote.length; i += CHUNK_SIZE) { + if (i > 0) { + await new Promise(resolve => setTimeout(resolve, CHUNK_DELAY_MS)) + } + + const chunk = channelsToLoadFromRemote.slice(i, i + CHUNK_SIZE) + const chunkResults = await Promise.all(chunk.map(processChannel)) + postListFromRemote.push(...chunkResults.flat()) + } postListFromRemote.sort((a, b) => { return b.publishedTime - a.publishedTime diff --git a/src/renderer/components/SubscriptionsVideos.vue b/src/renderer/components/SubscriptionsVideos.vue index 3627c8aff2302..e0f3d48dfdf47 100644 --- a/src/renderer/components/SubscriptionsVideos.vue +++ b/src/renderer/components/SubscriptionsVideos.vue @@ -184,14 +184,7 @@ async function loadVideosForSubscriptionsFromRemote() { let channelCount = 0 isLoading.value = true - let useRss = useRssFeeds.value - if (channelsToLoadFromRemote.length >= 125 && !useRss) { - showToast( - t('Subscriptions["This profile has a large number of subscriptions. Forcing RSS to avoid rate limiting"]'), - 10000 - ) - useRss = true - } + const useRss = useRssFeeds.value store.commit('setShowProgressBar', true) store.commit('setProgressBarPercentage', 0) @@ -199,8 +192,9 @@ async function loadVideosForSubscriptionsFromRemote() { errorChannels.value = [] const subscriptionUpdates = [] + const videoListFromRemote = [] - const videoListFromRemote = (await Promise.all(channelsToLoadFromRemote.map(async (channel) => { + const processChannel = async (channel) => { let videos, name, thumbnailUrl if (!process.env.SUPPORTS_LOCAL_API || backendPreference.value === 'invidious') { @@ -237,7 +231,25 @@ async function loadVideosForSubscriptionsFromRemote() { } return videos ?? [] - }))).flat() + } + + if (useRss) { + const results = await Promise.all(channelsToLoadFromRemote.map(processChannel)) + videoListFromRemote.push(...results.flat()) + } else { + const CHUNK_SIZE = 80 + const CHUNK_DELAY_MS = 2000 + + for (let i = 0; i < channelsToLoadFromRemote.length; i += CHUNK_SIZE) { + if (i > 0) { + await new Promise(resolve => setTimeout(resolve, CHUNK_DELAY_MS)) + } + + const chunk = channelsToLoadFromRemote.slice(i, i + CHUNK_SIZE) + const chunkResults = await Promise.all(chunk.map(processChannel)) + videoListFromRemote.push(...chunkResults.flat()) + } + } videoList.value = updateVideoListAfterProcessing(videoListFromRemote) isLoading.value = false diff --git a/src/renderer/views/Subscriptions/Subscriptions.vue b/src/renderer/views/Subscriptions/Subscriptions.vue index 6f36d1111e011..548586f67c0e8 100644 --- a/src/renderer/views/Subscriptions/Subscriptions.vue +++ b/src/renderer/views/Subscriptions/Subscriptions.vue @@ -157,11 +157,6 @@ const hideSubscriptionsCommunity = computed(() => { return store.getters.getHideSubscriptionsCommunity }) -/** @type {import('vue').ComputedRef} */ -const activeSubscriptionList = computed(() => { - return store.getters.getActiveProfile.subscriptions -}) - /** @type {import('vue').ComputedRef} */ const useRssFeeds = computed(() => { return store.getters.getUseRssFeeds @@ -196,7 +191,7 @@ const visibleTabs = computed(() => { } // community does not support rss - if (!hideSubscriptionsCommunity.value && !useRssFeeds.value && activeSubscriptionList.value.length < 125) { + if (!hideSubscriptionsCommunity.value && !useRssFeeds.value) { tabs.push('community') }