hide watched videos in the feed

This commit is contained in:
Bnyro
2022-09-10 19:08:50 +02:00
committed by Kavin
parent d65adfffc7
commit 8ae7a36627
4 changed files with 34 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
<template>
<div>
<div v-if="showVideo">
<router-link
:to="{
path: '/watch',
@@ -141,6 +141,10 @@ export default {
return {};
},
},
isFeed: {
type: Boolean,
default: false,
},
height: { type: String, default: "118" },
width: { type: String, default: "210" },
hideChannel: { type: Boolean, default: false },
@@ -151,8 +155,12 @@ export default {
data() {
return {
showModal: false,
showVideo: true,
};
},
mounted() {
this.shouldShowVideo();
},
methods: {
removeVideo() {
if (confirm(this.$t("actions.delete_playlist_video_confirm"))) {
@@ -173,6 +181,21 @@ export default {
});
}
},
shouldShowVideo() {
if (!this.isFeed || !this.getPreferenceBoolean("hideWatched", false)) return;
const objectStore = window.db.transaction("watch_history", "readonly").objectStore("watch_history");
objectStore.openCursor().onsuccess = event => {
const cursor = event.target.result;
if (cursor) {
if (cursor.value.videoId === this.video.url.replace("/watch?v=", "")) {
this.showVideo = false;
return;
}
cursor.continue();
}
};
},
},
computed: {
short() {