Skip to content

Commit

Permalink
fix(home): correctly filter recent only videos
Browse files Browse the repository at this point in the history
  • Loading branch information
AXeL-dev committed Sep 19, 2022
1 parent 599d272 commit 950e327
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/store/selectors/videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
ViewFilters,
} from 'types';
import { selectActiveChannels } from './channels';
import { selectViewFilters } from './settings';
import { selectSettings, selectViewFilters } from './settings';
import { elapsedDays } from 'helpers/utils';

export const selectVideos = (state: RootState) => state.videos.list;

Expand Down Expand Up @@ -39,14 +40,15 @@ export const selectRecentChannelVideos = (channel: Channel) =>
);

export const selectRecentOnlyVideos = (channel?: Channel) =>
createSelector(selectVideos, (videos) =>
createSelector(selectVideos, selectSettings, (videos, settings) =>
videos.filter(
({ flags = {}, channelId }) =>
({ flags = {}, channelId, publishedAt }) =>
Object.keys(flags).every(
(key) =>
['recent', 'notified'].includes(key) || !flags[key as VideoFlag],
) &&
(!channel || channel.id === channelId),
(!channel || channel.id === channelId) &&
elapsedDays(publishedAt) <= settings.recentVideosSeniority,
),
);

Expand Down

0 comments on commit 950e327

Please sign in to comment.