From e537d8a77e241c7e0f364cec26efe52a0b8aaece Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Wed, 23 Aug 2023 14:01:24 +0800 Subject: [PATCH 1/4] filterActiveLivestreamUris: remove bad loop The top loop must have come from experimentation when moving the filter from a selector to a util-function. It does a subset of the bottom loop, and would have included duplicates if `excludedChannelIds` was provided. --- ui/util/livestream.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/ui/util/livestream.js b/ui/util/livestream.js index 6e12077bc3..083d261114 100644 --- a/ui/util/livestream.js +++ b/ui/util/livestream.js @@ -103,23 +103,6 @@ export function filterActiveLivestreamUris( const filtered: Array = []; - for (const creatorId in activeLivestreamByCreatorId) { - const activeLivestream = activeLivestreamByCreatorId[creatorId]; - if (activeLivestream) { - if (channelIds) { - if (channelIds.includes(creatorId)) { - if (excludedChannelIds && !excludedChannelIds.includes(creatorId)) { - filtered.push(activeLivestream); - } - } - } else { - if (excludedChannelIds && !excludedChannelIds.includes(creatorId)) { - filtered.push(activeLivestream); - } - } - } - } - for (const creatorId in activeLivestreamByCreatorId) { const activeLivestream = activeLivestreamByCreatorId[creatorId]; if (activeLivestream) { From 0902677fb01ae80cab59699d3b5d8ce28643e329 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Wed, 23 Aug 2023 14:37:57 +0800 Subject: [PATCH 2/4] Homepage: honor 'excludedChannelIds' Closes 2933 --- ui/page/home/view.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/page/home/view.jsx b/ui/page/home/view.jsx index b32877007b..daf98208a7 100644 --- a/ui/page/home/view.jsx +++ b/ui/page/home/view.jsx @@ -124,12 +124,13 @@ function HomePage(props: Props) { } // -- Find livestreams related to the category: const rowChannelIds = row.options?.channelIds; + const rowExcludedChannelIds = row.options?.excludedChannelIds; cache[row.id] = { livestreamUris: row.id === 'FOLLOWING' - ? filterActiveLivestreamUris(subscribedChannelIds, null, al, lv) + ? filterActiveLivestreamUris(subscribedChannelIds, rowExcludedChannelIds, al, lv) : rowChannelIds - ? filterActiveLivestreamUris(rowChannelIds, null, al, lv) + ? filterActiveLivestreamUris(rowChannelIds, rowExcludedChannelIds, al, lv) : null, }; }); From 7c5ae8c4cf6a48209f4385ba0823667f63ec6d60 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Wed, 23 Aug 2023 15:10:12 +0800 Subject: [PATCH 3/4] CategoryPage: fix livestream filtering logic Closes 2933 ## Issue - CategoryPage was still using the old selector instead of `filterActiveLivestreamUris()`, which contains a prior fix. - The old selector logic assumes an "either or" of the whitelist/blacklist, but in reality both can be given. ## Change - Sync up the selector to do an "AND", where the blacklist works on top of the whitelist. - Doing the fix directly for now ... can DRY it up later. --- ui/redux/selectors/livestream.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/redux/selectors/livestream.js b/ui/redux/selectors/livestream.js index e57b350997..ebe83d10d9 100644 --- a/ui/redux/selectors/livestream.js +++ b/ui/redux/selectors/livestream.js @@ -67,10 +67,11 @@ export const selectFilteredActiveLivestreamUris = createCachedSelector( const activeCreatorLivestream = activeLivestreamByCreatorId[creatorId]; if (activeCreatorLivestream) { - const channelShouldFilter = !channelIds || channelIds.includes(creatorId); - const channelShouldExclude = excludedChannelIds && !excludedChannelIds.includes(creatorId); + const shouldInclude = + (!channelIds || channelIds.includes(creatorId)) && + (!excludedChannelIds || !excludedChannelIds.includes(creatorId)); - if (channelShouldFilter || channelShouldExclude) { + if (shouldInclude) { filteredLivestreams.push(activeCreatorLivestream); } } From 168b487453ef9cbc6adddb104b9b9375a134a438 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Wed, 23 Aug 2023 19:54:24 +0800 Subject: [PATCH 4/4] LivestreamSection: only apply excludedChannelIds for non-Wild-West Message from Tom: > use excluded on both livestream and regular content sections. If not wild west, don't use exluded --- ui/page/discover/view.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/page/discover/view.jsx b/ui/page/discover/view.jsx index 0ef59fd829..7733a883ed 100644 --- a/ui/page/discover/view.jsx +++ b/ui/page/discover/view.jsx @@ -97,7 +97,7 @@ function DiscoverPage(props: Props) {