Merge pull request #1420 from Bnyro/hideWatched

hide watched videos in the feed
This commit is contained in:
Kavin 2022-10-02 14:45:50 +01:00 committed by GitHub
commit 8273b6f999
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 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,19 @@ export default {
}); });
} }
}, },
shouldShowVideo() {
if (!this.isFeed || !this.getPreferenceBoolean("hideWatched", false)) return;
const objectStore = window.db.transaction("watch_history", "readonly").objectStore("watch_history");
const request = objectStore.get(this.video.url.substr(-11));
request.onsuccess = event => {
const video = event.target.result;
if (video && (video.currentTime ?? 0) > video.duration * 0.9) {
this.showVideo = false;
return;
}
};
},
}, },
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",