Skip to content

Commit

Permalink
refactor: use lodash sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Feb 3, 2022
1 parent 29903c0 commit a3205be
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/navsections/sectionBlueprintMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {shallowEqual} from 'react-redux';

import asyncLib from 'async';
import _ from 'lodash';
import log from 'loglevel';
import {Middleware} from 'redux';

Expand Down Expand Up @@ -273,10 +274,18 @@ const processSectionBlueprints = async (state: RootState, dispatch: AppDispatch)
...g,
visibleItemIds: g.itemIds.filter(itemId => itemInstanceMap[itemId].isVisible === true),
}));
const visibleItemIds = itemInstances?.filter(i => i.isVisible === true).map(i => i.id) || [];
const visibleItemIds = itemInstances
? _(itemInstances)
.filter(i => i.isVisible === true)
.map(i => i.id)
.value()
: [];
const visibleGroupIds = sectionBlueprint.customization?.emptyGroupText
? sectionInstanceGroups.map(g => g.id)
: sectionInstanceGroups.filter(g => g.visibleItemIds.length > 0).map(g => g.id);
: _(sectionInstanceGroups)
.filter(g => g.visibleItemIds.length > 0)
.map(g => g.id)
.value();
const sectionInstance: SectionInstance = {
id: sectionBlueprint.id,
rootSectionId: sectionBlueprint.rootSectionId,
Expand Down

0 comments on commit a3205be

Please sign in to comment.