Skip to content

Commit

Permalink
fix: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
olensmar committed Apr 14, 2023
1 parent 392b8b9 commit 50632e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from 'styled-components';

import {useAppSelector} from '@redux/hooks';
import {navigatorResourcesSelector} from '@redux/selectors/resourceSelectors';
import {navigatorResourcesCountSelector} from '@redux/selectors/resourceSelectors';

import {Colors, FontColors} from '@shared/styles';

Expand All @@ -13,11 +13,11 @@ type Props = {

function ResourceCounter({kind, isSelected, onClick}: Props) {
const isCollapsed = useAppSelector(state => state.ui.navigator.collapsedResourceKinds.includes(kind));
const navigatorResources = useAppSelector(state => navigatorResourcesSelector(state));
const navigatorResourcesCount = useAppSelector(navigatorResourcesCountSelector);

return (
<Counter selected={isSelected && isCollapsed} onClick={onClick}>
{navigatorResources.filter(r => r.kind === kind).length}
{navigatorResourcesCount}
</Counter>
);
}
Expand Down
5 changes: 5 additions & 0 deletions src/redux/selectors/resourceSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,8 @@ export const resourceNavigatorSelector = createSelector(
return list;
}
);

export const navigatorResourcesCountSelector = createSelector(
resourceNavigatorSelector,
navigatorResources => navigatorResources.length
);

0 comments on commit 50632e9

Please sign in to comment.