Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions src/renderer/components/SubscriptionsLive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,17 @@ 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)
attemptedFetch.value = true

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') {
Expand Down Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions src/renderer/components/SubscriptionsPosts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
32 changes: 22 additions & 10 deletions src/renderer/components/SubscriptionsVideos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,17 @@ 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)
attemptedFetch.value = true

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') {
Expand Down Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions src/renderer/views/Subscriptions/Subscriptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,6 @@ const hideSubscriptionsCommunity = computed(() => {
return store.getters.getHideSubscriptionsCommunity
})

/** @type {import('vue').ComputedRef<any[]>} */
const activeSubscriptionList = computed(() => {
return store.getters.getActiveProfile.subscriptions
})

/** @type {import('vue').ComputedRef<boolean>} */
const useRssFeeds = computed(() => {
return store.getters.getUseRssFeeds
Expand Down Expand Up @@ -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')
}

Expand Down