mirror of
https://github.com/TeamPiped/Piped.git
synced 2026-08-21 05:01:25 +00:00
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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user