1
0
Fork 0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2026-05-26 12:32:25 +00:00

Implement watched videos

Watched videos on your subscriptions feed will be darkened, and the
option to hide all of them has been added.

This only takes effect if you have enabled saving watched videos on the
server in the settings menu - default is off.
This commit is contained in:
Cadence Ember 2020-12-29 01:42:25 +13:00
parent c3afe77e2d
commit e0bc0d2e81
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
12 changed files with 106 additions and 34 deletions

View file

@ -22,6 +22,8 @@ module.exports = [
channels = db.prepare(`SELECT * FROM Channels WHERE ucid IN (${template}) ORDER BY name`).all(subscriptions)
// get refreshed status
refreshed = db.prepare(`SELECT min(refreshed) as min, max(refreshed) as max, count(refreshed) as count FROM Channels WHERE ucid IN (${template})`).get(subscriptions)
// get watched videos
const watchedVideos = user.getWatchedVideos()
// get videos
if (subscriptions.length) {
hasSubscriptions = true
@ -29,12 +31,15 @@ module.exports = [
videos = db.prepare(`SELECT * FROM Videos WHERE authorId IN (${template}) ORDER BY published DESC LIMIT 60`).all(subscriptions)
.map(video => {
video.publishedText = timeToPastText(video.published * 1000)
console.log(watchedVideos, video.videoId)
video.watched = watchedVideos.includes(video.videoId)
return video
})
}
}
const instanceOrigin = user.getSettingsOrDefaults().instance
return render(200, "pug/subscriptions.pug", {hasSubscriptions, videos, channels, refreshed, timeToPastText, instanceOrigin})
const settings = user.getSettingsOrDefaults()
const instanceOrigin = settings.instance
return render(200, "pug/subscriptions.pug", {settings, hasSubscriptions, videos, channels, refreshed, timeToPastText, instanceOrigin})
}
}
]