Add support for client-side watch history. (#370)

* Add support for client-side watch history.

* Update watched videos more often.
This commit is contained in:
Kavin
2021-08-22 15:57:09 +05:30
committed by GitHub
parent 6688fafeaa
commit 8feb4fbc41
13 changed files with 193 additions and 23 deletions

View File

@@ -144,6 +144,22 @@ export default {
},
mounted() {
this.getVideoData().then(() => {
(async () => {
if (window.db) {
var tx = window.db.transaction("watch_history", "readwrite");
var store = tx.objectStore("watch_history");
var video = {
videoId: this.getVideoId(),
title: this.video.title,
duration: this.video.duration,
thumbnail: this.video.thumbnailUrl,
uploaderUrl: this.video.uploaderUrl,
uploaderName: this.video.uploader,
watchedAt: Date.now(),
};
store.add(video);
}
})();
if (this.active) this.$refs.videoPlayer.loadVideo();
});
this.getSponsors();
@@ -163,13 +179,6 @@ export default {
this.active = false;
window.removeEventListener("scroll", this.handleScroll);
},
watch: {
"$route.query.v": function(v) {
if (v) {
window.scrollTo(0, 0);
}
},
},
methods: {
fetchVideo() {
return this.fetchJson(this.apiUrl() + "/streams/" + this.getVideoId());