Skip to content

Commit

Permalink
deeper iteration, no local storage for explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
dlicheva committed Jun 27, 2024
1 parent 9f5b9f1 commit 91023bf
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions application/frontend/src/providers/DataProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@ export const DataProvider = ({ children }: { children: React.ReactNode }) => {
keyPath.push(selfKey);

const storedDoc = structuredClone(dataStore[selfKey]);

const initialLinks = storedDoc.links;
let initialLinks = storedDoc.links;
let creLinks = initialLinks.filter(
(x) => x.document && !keyPath.includes(getStoreKey(x.document)) && getStoreKey(x.document) in dataStore
(x) => !!x.document && !keyPath.includes(getStoreKey(x.document)) && getStoreKey(x.document) in dataStore
);

if (!creLinks.length) {
// leaves of the tree can be links that are included in the keyPath.
// If we don't add this here, the leaves are filtered out above (see ticket #514 on OpenCRE)
storedDoc.links = initialLinks.filter((x) => x.ltype === 'Contains' && !!x.document);
return storedDoc;
if (!creLinks.length && !initialLinks.length) {
return storedDoc;
}
else if (!creLinks.length && initialLinks.length>0) {
creLinks = initialLinks.filter((x) => x.ltype === 'Contains' && !!x.document && getStoreKey(x.document) in dataStore);
}

//continue traversing the tree
Expand All @@ -74,7 +73,8 @@ export const DataProvider = ({ children }: { children: React.ReactNode }) => {
try {
const result = await axios.get(`${apiUrl}/root_cres`);
const treeData = result.data.data.map((x) => buildTree(x));
setLocalStorageObject(DATA_TREE_KEY, treeData, TWO_DAYS_MILLISECONDS);
// the tree doesn't fit into local storage:
// setLocalStorageObject(DATA_TREE_KEY, treeData, TWO_DAYS_MILLISECONDS);
setDataTree(treeData);
} catch (error) {
console.error(error);
Expand Down

0 comments on commit 91023bf

Please sign in to comment.