Skip to content

Commit

Permalink
Livestreams: fixes related to 'excludedChannelIds' #2936
Browse files Browse the repository at this point in the history
  • Loading branch information
infinite-persistence committed Aug 23, 2023
2 parents bd92ac6 + 168b487 commit d1c5676
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 23 deletions.
2 changes: 1 addition & 1 deletion ui/page/discover/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function DiscoverPage(props: Props) {
<LivestreamSection
tileLayout={repostedUri ? false : tileLayout}
channelIds={channelIds}
excludedChannelIds={excludedChannelIds}
excludedChannelIds={isWildWest ? excludedChannelIds : null}
searchLanguages={dynamicRouteProps?.options?.searchLanguages}
langParam={langParam}
hideMembersOnlyContent={hideMembersOnlyContent}
Expand Down
5 changes: 3 additions & 2 deletions ui/page/home/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
});
Expand Down
7 changes: 4 additions & 3 deletions ui/redux/selectors/livestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
17 changes: 0 additions & 17 deletions ui/util/livestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,6 @@ export function filterActiveLivestreamUris(

const filtered: Array<LivestreamActiveClaim> = [];

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) {
Expand Down

0 comments on commit d1c5676

Please sign in to comment.