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,6 +20,7 @@
<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">
<div v-if="!isBlocked(result)">
<VideoItem v-if="shouldUseVideoItem(result)" :video="result" height="94" width="168" /> <VideoItem v-if="shouldUseVideoItem(result)" :video="result" height="94" width="168" />
<div v-if="!shouldUseVideoItem(result)"> <div v-if="!shouldUseVideoItem(result)">
<router-link :to="result.url"> <router-link :to="result.url">
@ -47,6 +48,7 @@
<br /> <br />
</div> </div>
</div>
</template> </template>
</div> </div>
</template> </template>
@ -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() {