add option to block channels

This commit is contained in:
Bnyro 2022-08-27 16:32:09 +02:00
parent 4d9e6865ce
commit b46555fbcd
4 changed files with 54 additions and 25 deletions

View file

@ -286,6 +286,17 @@
</div> </div>
<br /> <br />
</div> </div>
<h2 class="text-center" v-t="'actions.blocked_channels'"></h2>
<label class="pref" for="blockedChannels">
<strong v-t="'actions.blocked_channels'" />
<input
id="blockedChannels"
v-model="blockedChannels"
@change="onChange($event)"
class="input w-auto mr-2"
type="text"
/>
</label>
<h2 id="instancesList" v-t="'actions.instances_list'" /> <h2 id="instancesList" v-t="'actions.instances_list'" />
<table class="table"> <table class="table">
<thead> <thead>
@ -403,6 +414,7 @@ export default {
disableLBRY: false, disableLBRY: false,
proxyLBRY: false, proxyLBRY: false,
password: null, password: null,
blockedChannels: "",
}; };
}, },
activated() { activated() {
@ -492,6 +504,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.blockedChannels = this.getPreferenceString("blockedChannels", "");
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(
@ -549,6 +562,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("blockedChannels", this.blockedChannels);
if (shouldReload) window.location.reload(); if (shouldReload) window.location.reload();
} }

View file

@ -20,32 +20,34 @@
<div v-if="results" class="video-grid"> <div v-if="results" class="video-grid">
<template v-for="result in results.items" :key="result.url"> <template v-for="result in results.items" :key="result.url">
<VideoItem v-if="shouldUseVideoItem(result)" :video="result" height="94" width="168" /> <div v-if="!isBlocked(result)">
<div v-if="!shouldUseVideoItem(result)"> <VideoItem v-if="shouldUseVideoItem(result)" :video="result" height="94" width="168" />
<router-link :to="result.url"> <div v-if="!shouldUseVideoItem(result)">
<div class="relative"> <router-link :to="result.url">
<img class="w-full" :src="result.thumbnail" loading="lazy" /> <div class="relative">
</div> <img class="w-full" :src="result.thumbnail" loading="lazy" />
<p> </div>
<span v-text="result.name" /> <p>
<font-awesome-icon class="ml-1.5" v-if="result.verified" icon="check" /> <span v-text="result.name" />
</p> <font-awesome-icon class="ml-1.5" v-if="result.verified" icon="check" />
</router-link> </p>
<p v-if="result.description" v-text="result.description" /> </router-link>
<router-link v-if="result.uploaderUrl" class="link" :to="result.uploaderUrl"> <p v-if="result.description" v-text="result.description" />
<p> <router-link v-if="result.uploaderUrl" class="link" :to="result.uploaderUrl">
<span v-text="result.uploader" /> <p>
<font-awesome-icon class="ml-1.5" v-if="result.uploaderVerified" icon="check" /> <span v-text="result.uploader" />
</p> <font-awesome-icon class="ml-1.5" v-if="result.uploaderVerified" icon="check" />
</router-link> </p>
</router-link>
<a v-if="result.uploaderName" class="link" v-text="result.uploaderName" /> <a v-if="result.uploaderName" class="link" v-text="result.uploaderName" />
<template v-if="result.videos >= 0"> <template v-if="result.videos >= 0">
<br v-if="result.uploaderName" /> <br v-if="result.uploaderName" />
<strong v-text="`${result.videos} ${$t('video.videos')}`" /> <strong v-text="`${result.videos} ${$t('video.videos')}`" />
</template> </template>
<br /> <br />
</div>
</div> </div>
</template> </template>
</div> </div>
@ -138,6 +140,13 @@ export default {
return true; return true;
} }
}, },
isBlocked(result) {
if (!result.uploaderUrl) {
// item is a channel
return this.isChannelBlocked(result.url.replace("/channel/", ""));
}
return this.isChannelBlocked(result.uploaderUrl.replace("/channel/", ""));
},
}, },
}; };
</script> </script>

View file

@ -97,7 +97,8 @@
"confirm_reset_preferences": "Are you sure you want to reset your preferences?", "confirm_reset_preferences": "Are you sure you want to reset your preferences?",
"backup_preferences": "Backup preferences", "backup_preferences": "Backup preferences",
"restore_preferences": "Restore preferences", "restore_preferences": "Restore preferences",
"back_to_home": "Back to home" "back_to_home": "Back to home",
"blocked_channels": "Blocked channels"
}, },
"comment": { "comment": {
"pinned_by": "Pinned by", "pinned_by": "Pinned by",

View file

@ -231,6 +231,11 @@ const mixin = {
elem.click(); elem.click();
elem.remove(); elem.remove();
}, },
isChannelBlocked(channelId) {
const blockedChannels = localStorage.getItem("blockedChannels");
if (!blockedChannels) return false;
return blockedChannels.split(",").includes(channelId);
},
}, },
computed: { computed: {
theme() { theme() {