Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/514 🐛 Fix explorer incomplete #519

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading