1
0
Fork 0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2026-03-02 02:31:35 +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

@ -57,6 +57,22 @@ class User {
return false
}
}
getWatchedVideos() {
const settings = this.getSettingsOrDefaults()
if (this.token && settings.save_history) {
return db.prepare("SELECT videoID FROM WatchedVideos WHERE token = ?").pluck().all(this.token)
} else {
return []
}
}
addWatchedVideoMaybe(videoID) {
const settings = this.getSettingsOrDefaults()
if (videoID && this.token && settings.save_history) {
db.prepare("INSERT OR IGNORE INTO WatchedVideos (token, videoID) VALUES (?, ?)").run([this.token, videoID])
}
}
}
/**

View file

@ -28,6 +28,11 @@ const deltas = [
function() {
db.prepare("ALTER TABLE Settings ADD COLUMN local INTEGER DEFAULT 0")
.run()
},
// 3: +WatchedVideos
function() {
db.prepare("CREATE TABLE WatchedVideos (token TEXT NOT NULL, videoID TEXT NOT NULL, PRIMARY KEY (token, videoID))")
.run()
}
]