Skip to content

Commit

Permalink
- fix stringify reaching its limits (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
haideriqbal authored May 29, 2024
1 parent 7f96c14 commit 82802d2
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions frontend/src/pages/ontologies/entities/EntityTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Radio,
RadioGroup,
} from "@mui/material";
import { useCallback, useEffect } from "react";
import { useCallback, useEffect, useRef } from "react";
import urlJoin from "url-join";
import { useAppDispatch, useAppSelector } from "../../../app/hooks";
import { theme } from "../../../app/mui";
Expand Down Expand Up @@ -159,7 +159,24 @@ export default function EntityTree({
showObsoleteEnabled,
]);

const prevNodeChildrenRef = useRef(nodeChildren);

const haveRelevantPartsChanged = (prev, next) => {
if (!prev || !next) return true;
const prevKeys = Object.keys(prev);
const nextKeys = Object.keys(next);
if (prevKeys.length !== nextKeys.length) return true;
for (let key of prevKeys) {
if (prev[key] !== next[key]) return true;
}
return false;
};

useEffect(() => {
const prevNodeChildren = prevNodeChildrenRef.current;
if (!haveRelevantPartsChanged(prevNodeChildren, nodeChildren)) {
return;
}
let nodesMissingChildren: string[] = manuallyExpandedNodes.filter(
(absoluteIdentity) =>
nodesWithChildrenLoaded.indexOf(absoluteIdentity) === -1
Expand All @@ -174,10 +191,6 @@ export default function EntityTree({
),
];
}
// console.log(
// "!!!! Getting missing node children: " +
// JSON.stringify(nodesMissingChildren)
// );

let promises: any = [];
for (let absId of nodesMissingChildren) {
Expand All @@ -204,7 +217,7 @@ export default function EntityTree({
lang,
JSON.stringify(manuallyExpandedNodes),
JSON.stringify(automaticallyExpandedNodes),
JSON.stringify(nodeChildren),
nodeChildren,
ontology.getOntologyId(),
entityType,
preferredRoots,
Expand Down

0 comments on commit 82802d2

Please sign in to comment.