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:
parent
c3afe77e2d
commit
e0bc0d2e81
12 changed files with 106 additions and 34 deletions
|
|
@ -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])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue