mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
parent
4ec67a4884
commit
6ee9592218
1 changed files with 19 additions and 9 deletions
|
@ -216,19 +216,29 @@ export default {
|
|||
mounted() {
|
||||
this.getVideoData().then(() => {
|
||||
(async () => {
|
||||
const videoId = this.getVideoId();
|
||||
const instance = this;
|
||||
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,
|
||||
var request = store.get(videoId);
|
||||
request.onsuccess = function(event) {
|
||||
var video = event.target.result;
|
||||
if (video) {
|
||||
video.watchedAt = Date.now();
|
||||
} else {
|
||||
video = {
|
||||
videoId: videoId,
|
||||
title: instance.video.title,
|
||||
duration: instance.video.duration,
|
||||
thumbnail: instance.video.thumbnailUrl,
|
||||
uploaderUrl: instance.video.uploaderUrl,
|
||||
uploaderName: instance.video.uploader,
|
||||
watchedAt: Date.now(),
|
||||
};
|
||||
store.add(video);
|
||||
}
|
||||
store.put(video);
|
||||
};
|
||||
}
|
||||
})();
|
||||
if (this.active) this.$refs.videoPlayer.loadVideo();
|
||||
|
|
Loading…
Reference in a new issue