1
0
mirror of https://github.com/TeamPiped/Piped.git synced 2024-12-14 14:20:28 +05:30

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
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
4 changed files with 34 additions and 3 deletions

View File

@ -18,7 +18,7 @@
<hr /> <hr />
<div class="video-grid"> <div class="video-grid">
<VideoItem v-for="video in videos" :key="video.url" :video="video" /> <VideoItem :is-feed="true" v-for="video in videos" :key="video.url" :video="video" />
</div> </div>
</template> </template>

View File

@ -116,6 +116,10 @@
@change="onChange($event)" @change="onChange($event)"
/> />
</label> </label>
<label v-if="watchHistory" class="pref" for="chkHideWatched">
<strong v-t="'actions.hide_watched'" />
<input id="chkHideWatched" v-model="hideWatched" class="checkbox" type="checkbox" @change="onChange($event)" />
</label>
<label class="pref" for="ddlEnabledCodecs"> <label class="pref" for="ddlEnabledCodecs">
<strong v-t="'actions.enabled_codecs'" /> <strong v-t="'actions.enabled_codecs'" />
<select <select
@ -366,6 +370,7 @@ export default {
minimizeRecommendations: false, minimizeRecommendations: false,
watchHistory: false, watchHistory: false,
searchHistory: false, searchHistory: false,
hideWatched: false,
selectedLanguage: "en", selectedLanguage: "en",
languages: [ languages: [
{ code: "ar", name: "Arabic" }, { code: "ar", name: "Arabic" },
@ -505,6 +510,7 @@ export default {
this.enabledCodecs = this.getPreferenceString("enabledCodecs", "vp9,avc").split(","); this.enabledCodecs = this.getPreferenceString("enabledCodecs", "vp9,avc").split(",");
this.disableLBRY = this.getPreferenceBoolean("disableLBRY", false); this.disableLBRY = this.getPreferenceBoolean("disableLBRY", false);
this.proxyLBRY = this.getPreferenceBoolean("proxyLBRY", false); this.proxyLBRY = this.getPreferenceBoolean("proxyLBRY", false);
this.hideWatched = this.getPreferenceBoolean("hideWatched", false);
if (this.selectedLanguage != "en") { if (this.selectedLanguage != "en") {
try { try {
this.CountryMap = await import(`../utils/CountryMaps/${this.selectedLanguage}.json`).then( this.CountryMap = await import(`../utils/CountryMaps/${this.selectedLanguage}.json`).then(
@ -564,6 +570,7 @@ export default {
localStorage.setItem("enabledCodecs", this.enabledCodecs.join(",")); localStorage.setItem("enabledCodecs", this.enabledCodecs.join(","));
localStorage.setItem("disableLBRY", this.disableLBRY); localStorage.setItem("disableLBRY", this.disableLBRY);
localStorage.setItem("proxyLBRY", this.proxyLBRY); localStorage.setItem("proxyLBRY", this.proxyLBRY);
localStorage.setItem("hideWatched", this.hideWatched);
if (shouldReload) window.location.reload(); if (shouldReload) window.location.reload();
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div> <div v-if="showVideo">
<router-link <router-link
:to="{ :to="{
path: '/watch', path: '/watch',
@ -141,6 +141,10 @@ export default {
return {}; return {};
}, },
}, },
isFeed: {
type: Boolean,
default: false,
},
height: { type: String, default: "118" }, height: { type: String, default: "118" },
width: { type: String, default: "210" }, width: { type: String, default: "210" },
hideChannel: { type: Boolean, default: false }, hideChannel: { type: Boolean, default: false },
@ -151,8 +155,12 @@ export default {
data() { data() {
return { return {
showModal: false, showModal: false,
showVideo: true,
}; };
}, },
mounted() {
this.shouldShowVideo();
},
methods: { methods: {
removeVideo() { removeVideo() {
if (confirm(this.$t("actions.delete_playlist_video_confirm"))) { 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: { computed: {
short() { short() {

View File

@ -107,7 +107,8 @@
"copy_link": "Copy link", "copy_link": "Copy link",
"time_code": "Time code (in seconds)", "time_code": "Time code (in seconds)",
"show_chapters": "Chapters", "show_chapters": "Chapters",
"store_search_history": "Store Search history" "store_search_history": "Store Search history",
"hide_watched": "Hide watched videos in the feed"
}, },
"comment": { "comment": {
"pinned_by": "Pinned by", "pinned_by": "Pinned by",