Skip to content

Commit

Permalink
show nwb files only
Browse files Browse the repository at this point in the history
  • Loading branch information
magland committed Feb 11, 2025
1 parent b623d4c commit 389f56f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/pages/common/DatasetWorkspace/DatasetMainTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ const expandedDirectoriesReducer = (

type LoadedFiles = DatasetFile[];

type LoadedFilesAction = {
type: "add";
file: DatasetFile;
};
type LoadedFilesAction =
| {
type: "add";
file: DatasetFile;
}
| {
type: "clear";
};

const loadedFilesReducer = (
state: LoadedFiles,
Expand All @@ -49,6 +53,9 @@ const loadedFilesReducer = (
if (state.find((a) => a.id === action.file.id)) return state;
return [...state, action.file];
}
case "clear": {
return [];
}
default: {
throw Error("Unexpected action type");
}
Expand Down Expand Up @@ -78,6 +85,7 @@ const DatasetMainTab: FunctionComponent<Props> = ({

const [loadedFiles, loadedFilesDispatch] = useReducer(loadedFilesReducer, []);
useEffect(() => {
loadedFilesDispatch({ type: "clear" });
for (const f of topLevelFiles) {
loadedFilesDispatch({ type: "add", file: f });
}
Expand Down

0 comments on commit 389f56f

Please sign in to comment.