Skip to content

Commit

Permalink
Do not overwrite cache entries when hitting RSS ratelimits (#5756)
Browse files Browse the repository at this point in the history
  • Loading branch information
absidue committed Sep 29, 2024
1 parent 6f3748d commit 748e979
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 15 deletions.
19 changes: 14 additions & 5 deletions src/renderer/components/subscriptions-live/subscriptions-live.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,13 @@ export default defineComponent({
channelCount++
const percentageComplete = (channelCount / channelsToLoadFromRemote.length) * 100
this.setProgressBarPercentage(percentageComplete)
this.updateSubscriptionLiveCacheByChannel({
channelId: channel.id,
videos: videos
})

if (videos != null) {
this.updateSubscriptionLiveCacheByChannel({
channelId: channel.id,
videos: videos
})
}

if (name || thumbnailUrl) {
subscriptionUpdates.push({
Expand All @@ -219,7 +222,7 @@ export default defineComponent({
})
}

return videos
return videos ?? []
}))).flat()

this.videoList = updateVideoListAfterProcessing(videoListFromRemote)
Expand Down Expand Up @@ -277,6 +280,12 @@ export default defineComponent({
try {
const response = await fetch(feedUrl)

if (response.status === 403) {
return {
videos: null
}
}

if (response.status === 404) {
// playlists don't exist if the channel was terminated but also if it doesn't have the tab,
// so we need to check the channel feed too before deciding it errored, as that only 404s if the channel was terminated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,13 @@ export default defineComponent({
channelCount++
const percentageComplete = (channelCount / channelsToLoadFromRemote.length) * 100
this.setProgressBarPercentage(percentageComplete)
this.updateSubscriptionShortsCacheByChannel({
channelId: channel.id,
videos: videos
})

if (videos != null) {
this.updateSubscriptionShortsCacheByChannel({
channelId: channel.id,
videos: videos
})
}

if (name) {
subscriptionUpdates.push({
Expand All @@ -195,7 +198,7 @@ export default defineComponent({
})
}

return videos
return videos ?? []
}))).flat()

this.videoList = updateVideoListAfterProcessing(videoListFromRemote)
Expand All @@ -213,6 +216,12 @@ export default defineComponent({
try {
const response = await fetch(feedUrl)

if (response.status === 403) {
return {
videos: null
}
}

if (response.status === 404) {
// playlists don't exist if the channel was terminated but also if it doesn't have the tab,
// so we need to check the channel feed too before deciding it errored, as that only 404s if the channel was terminated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,13 @@ export default defineComponent({
channelCount++
const percentageComplete = (channelCount / channelsToLoadFromRemote.length) * 100
this.setProgressBarPercentage(percentageComplete)
this.updateSubscriptionVideosCacheByChannel({
channelId: channel.id,
videos: videos
})

if (videos != null) {
this.updateSubscriptionVideosCacheByChannel({
channelId: channel.id,
videos: videos
})
}

if (name || thumbnailUrl) {
subscriptionUpdates.push({
Expand All @@ -223,7 +226,7 @@ export default defineComponent({
})
}

return videos
return videos ?? []
}))).flat()

this.videoList = updateVideoListAfterProcessing(videoListFromRemote)
Expand Down Expand Up @@ -281,6 +284,12 @@ export default defineComponent({
try {
const response = await fetch(feedUrl)

if (response.status === 403) {
return {
videos: null
}
}

if (response.status === 404) {
// playlists don't exist if the channel was terminated but also if it doesn't have the tab,
// so we need to check the channel feed too before deciding it errored, as that only 404s if the channel was terminated
Expand Down

0 comments on commit 748e979

Please sign in to comment.