Skip to content

Commit

Permalink
fix: exclude removed channels videos from watch later videos count
Browse files Browse the repository at this point in the history
  • Loading branch information
AXeL-dev committed Jul 9, 2022
1 parent b9e32e3 commit 5e55776
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/store/selectors/videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ViewFilter,
ViewFilters,
} from 'types';
import { selectHiddenChannels } from './channels';
import { selectChannels, selectHiddenChannels } from './channels';
import { selectViewFilters } from './settings';

export const selectVideos = (state: RootState) => state.videos.list;
Expand Down Expand Up @@ -84,12 +84,16 @@ export const selectWatchLaterVideos = (channel?: Channel) =>
export const selectWatchLaterVideosCount = createSelector(
selectVideos,
selectViewFilters(HomeView.WatchLater),
selectHiddenChannels,
(videos, filters, hiddenChannels) => {
const hiddenChannelsIds = hiddenChannels.map(({ id }) => id);
selectChannels,
(videos, filters, channels) => {
const channelsIds = channels.map(({ id }) => id);
const hiddenChannelsIds = channels
.filter(({ isHidden }) => isHidden)
.map(({ id }) => id);
return videos.filter(
({ flags, channelId }) =>
flags.toWatchLater &&
channelsIds.includes(channelId) &&
!hiddenChannelsIds.includes(channelId) &&
filterVideoByFlags(flags, filters)
).length;
Expand Down

0 comments on commit 5e55776

Please sign in to comment.