Skip to content

Commit

Permalink
Fix filtering error
Browse files Browse the repository at this point in the history
  • Loading branch information
ripry committed Jan 28, 2021
1 parent 5ff3472 commit 7d6fbcf
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions node/src/ts/visualizer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ const App: React.FC<AppProps> = (props) => {
})
}, [content, rawState]) // eslint-disable-line react-hooks/exhaustive-deps

const restrictNoChildClass = true
const { lowerLimitOfClassEntities } = useSelector(selector)
useEffect(() => {
if (isEmptyContent(rawState)) {
Expand All @@ -224,14 +223,18 @@ const App: React.FC<AppProps> = (props) => {
return _.flatMap(elem.children, flattenChildren).concat([elem])
}

const urisToFilter = rawState.structure
const urisToHide = rawState.structure
.flatMap((elem) => flattenChildren(elem))
.filter((elem) => !restrictNoChildClass || !elem.children)
.filter((elem) => {
const classDetail = rawState.classes[elem.uri]
return (
elem.children === undefined &&
(classDetail === undefined ||
classDetail.entities === undefined ||
classDetail.entities < lowerLimitOfClassEntities)
)
})
.map((elem) => elem.uri)
const urisToHide = urisToFilter.filter((uri) => {
const { entities } = rawState.classes[uri]
return entities === undefined || entities < lowerLimitOfClassEntities
})

const shouldHideElement = (uri: string) => urisToHide.includes(uri)
const filteredState = filterContent(
Expand Down

0 comments on commit 7d6fbcf

Please sign in to comment.