mirror of https://git.sr.ht/~cadence/cloudtube
Compare commits
2 Commits
739f537bc7
...
83c34f75d9
Author | SHA1 | Date |
---|---|---|
Cadence Ember | 83c34f75d9 | |
Cadence Ember | 57e4507bff |
|
@ -87,12 +87,12 @@ class Refresher {
|
||||||
})
|
})
|
||||||
// update channel refreshed
|
// update channel refreshed
|
||||||
prepared.channel_refreshed_update.run(Date.now(), ucid)
|
prepared.channel_refreshed_update.run(Date.now(), ucid)
|
||||||
console.log(`updated ${root.length} videos for channel ${ucid}`)
|
// console.log(`updated ${root.length} videos for channel ${ucid}`)
|
||||||
} else if (root.identifier === "PUBLISHED_DATES_NOT_PROVIDED") {
|
} else if (root.identifier === "PUBLISHED_DATES_NOT_PROVIDED") {
|
||||||
return [] // nothing we can do. skip this iteration.
|
return [] // nothing we can do. skip this iteration.
|
||||||
} else if (root.identifier === "NOT_FOUND") {
|
} else if (root.identifier === "NOT_FOUND") {
|
||||||
// the channel does not exist. we should unsubscribe all users so we don't try again.
|
// the channel does not exist. we should unsubscribe all users so we don't try again.
|
||||||
console.log(`channel ${ucid} does not exist, unsubscribing all users`)
|
// console.log(`channel ${ucid} does not exist, unsubscribing all users`)
|
||||||
prepared.unsubscribe_all_from_channel.run(ucid)
|
prepared.unsubscribe_all_from_channel.run(ucid)
|
||||||
} else {
|
} else {
|
||||||
throw new Error(root.error)
|
throw new Error(root.error)
|
||||||
|
@ -105,7 +105,7 @@ class Refresher {
|
||||||
const timeSinceLastLoop = Date.now() - this.refreshQueue.lastLoadTime
|
const timeSinceLastLoop = Date.now() - this.refreshQueue.lastLoadTime
|
||||||
if (timeSinceLastLoop < constants.caching.subscriptions_refresh_loop_min) {
|
if (timeSinceLastLoop < constants.caching.subscriptions_refresh_loop_min) {
|
||||||
const timeToWait = constants.caching.subscriptions_refresh_loop_min - timeSinceLastLoop
|
const timeToWait = constants.caching.subscriptions_refresh_loop_min - timeSinceLastLoop
|
||||||
console.log(`waiting ${timeToWait} before next loop`)
|
// console.log(`waiting ${timeToWait} before next loop`)
|
||||||
this.state = this.sym.WAITING
|
this.state = this.sym.WAITING
|
||||||
this.waitingTimeout = setTimeout(() => this.next(), timeToWait)
|
this.waitingTimeout = setTimeout(() => this.next(), timeToWait)
|
||||||
return
|
return
|
||||||
|
@ -117,7 +117,15 @@ class Refresher {
|
||||||
if (!this.refreshQueue.isEmpty()) {
|
if (!this.refreshQueue.isEmpty()) {
|
||||||
this.state = this.sym.ACTIVE
|
this.state = this.sym.ACTIVE
|
||||||
const ucid = this.refreshQueue.next()
|
const ucid = this.refreshQueue.next()
|
||||||
this.refreshChannel(ucid).then(() => this.next())
|
this.refreshChannel(ucid).then(() => this.next()).catch(error => {
|
||||||
|
// Problems related to fetching from the instance?
|
||||||
|
// All we can do is retry later.
|
||||||
|
// However, skip this channel this time in case the problem will occur every time.
|
||||||
|
console.error("Error in background refresh:\n", error)
|
||||||
|
setTimeout(() => {
|
||||||
|
this.next()
|
||||||
|
}, 10e3)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
this.state = this.sym.EMPTY
|
this.state = this.sym.EMPTY
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue