From b46555fbcde624ab1790a00e5420e3fcb06485ea Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 27 Aug 2022 16:32:09 +0200 Subject: [PATCH] add option to block channels --- src/components/PreferencesPage.vue | 14 ++++++++ src/components/SearchResults.vue | 57 +++++++++++++++++------------- src/locales/en.json | 3 +- src/main.js | 5 +++ 4 files changed, 54 insertions(+), 25 deletions(-) diff --git a/src/components/PreferencesPage.vue b/src/components/PreferencesPage.vue index ef693918..7942c229 100644 --- a/src/components/PreferencesPage.vue +++ b/src/components/PreferencesPage.vue @@ -286,6 +286,17 @@
+

+

@@ -403,6 +414,7 @@ export default { disableLBRY: false, proxyLBRY: false, password: null, + blockedChannels: "", }; }, activated() { @@ -492,6 +504,7 @@ export default { this.enabledCodecs = this.getPreferenceString("enabledCodecs", "vp9,avc").split(","); this.disableLBRY = this.getPreferenceBoolean("disableLBRY", false); this.proxyLBRY = this.getPreferenceBoolean("proxyLBRY", false); + this.blockedChannels = this.getPreferenceString("blockedChannels", ""); if (this.selectedLanguage != "en") { try { this.CountryMap = await import(`../utils/CountryMaps/${this.selectedLanguage}.json`).then( @@ -549,6 +562,7 @@ export default { localStorage.setItem("enabledCodecs", this.enabledCodecs.join(",")); localStorage.setItem("disableLBRY", this.disableLBRY); localStorage.setItem("proxyLBRY", this.proxyLBRY); + localStorage.setItem("blockedChannels", this.blockedChannels); if (shouldReload) window.location.reload(); } diff --git a/src/components/SearchResults.vue b/src/components/SearchResults.vue index 0e16f69a..1ae0d0da 100644 --- a/src/components/SearchResults.vue +++ b/src/components/SearchResults.vue @@ -20,32 +20,34 @@
@@ -138,6 +140,13 @@ export default { 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/", "")); + }, }, }; diff --git a/src/locales/en.json b/src/locales/en.json index ac4e4322..974bb550 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -97,7 +97,8 @@ "confirm_reset_preferences": "Are you sure you want to reset your preferences?", "backup_preferences": "Backup preferences", "restore_preferences": "Restore preferences", - "back_to_home": "Back to home" + "back_to_home": "Back to home", + "blocked_channels": "Blocked channels" }, "comment": { "pinned_by": "Pinned by", diff --git a/src/main.js b/src/main.js index 6a631ef6..1845e27d 100644 --- a/src/main.js +++ b/src/main.js @@ -231,6 +231,11 @@ const mixin = { elem.click(); elem.remove(); }, + isChannelBlocked(channelId) { + const blockedChannels = localStorage.getItem("blockedChannels"); + if (!blockedChannels) return false; + return blockedChannels.split(",").includes(channelId); + }, }, computed: { theme() {