Skip to content

Commit

Permalink
fix: multi-rendering issue in ChannelVideosProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
AXeL-dev committed Nov 7, 2022
1 parent e9e662b commit d1fe507
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/providers/ChannelVideosProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ export const ChannelVideosProvider: FC = memo(({ children }) => {
const channelsMap = useRef<{ [key: string]: Map<string, ChannelData> }>(
initialChannelsMap,
);
const hiddenChannels = useAppSelector(selectHiddenChannels).map(
({ id }) => id,
);
const hiddenChannels = useAppSelector(selectHiddenChannels);

const updateCount = useCallback(
debounce((view: HomeView, count: ChannelVideosCount) => {
Expand All @@ -80,8 +78,9 @@ export const ChannelVideosProvider: FC = memo(({ children }) => {

const getCount = (view: HomeView) => {
const channelsData = Array.from(channelsMap.current[view].values());
const hiddenChannelsIds = hiddenChannels.map(({ id }) => id);
const count = channelsData
.filter(({ channel }) => !hiddenChannels.includes(channel.id))
.filter(({ channel }) => !hiddenChannelsIds.includes(channel.id))
.reduce(
(acc, data) => ({
current: acc.current + (data.items?.length || 0),
Expand Down

0 comments on commit d1fe507

Please sign in to comment.