Skip to content

Commit

Permalink
refactor(ui): small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Anis SMAIL committed Dec 18, 2024
1 parent 03c9ef0 commit 442cd41
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions webapp/src/components/App/Studies/StudyTree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,12 @@ function StudyTree() {
const dispatch = useAppDispatch();
const [t] = useTranslation();

////////////////////////////////////////////////////////////////
// initialize
////////////////////////////////////////////////////////////////

// Initialize folders once we have the tree
// we use useUpdateEffectOnce because at first render initialStudiesTree isn't initialized
useUpdateEffectOnce(() => {
updateTree("root", initialStudiesTree);
}, [initialStudiesTree]);

////////////////////////////////////////////////////////////////
// utils
////////////////////////////////////////////////////////////////

/**
* This function is called at the initialization of the component and when the user clicks on a folder.
*
Expand Down Expand Up @@ -85,13 +77,12 @@ function StudyTree() {
);
}
} else {
/* If the user clicks on a folder, we add the path of the clicked folder to the list of paths to fetch.
* as well as the path of the children of the clicked folder.
* If we don't fetch the subfolders of the children then we won't know if they're themselves folders, which we need
* to know to display the little arrow next to the subfolder.
* On the other hand, if we fetch only the subfolders of the children, then we won't fetch their "siblings" folder
* if one of them is added.
*/
// If the user clicks on a folder, we add the path of the clicked folder to the list of paths to fetch.
// as well as the path of the children of the clicked folder.
// If we don't fetch the subfolders of the children then we won't know if they're themselves folders, which we need
// to know to display the little arrow next to the subfolder.
// On the other hand, if we fetch only the subfolders of the children, then we won't fetch their "siblings" folder
// if one of them is added.
chidrenPaths = [studyTreeNode.path].concat(chidrenPaths);
}

Expand Down

0 comments on commit 442cd41

Please sign in to comment.