mirror of
https://github.com/morluto/rea.git
synced 2026-12-05 14:31:22 +00:00
refactor(views): share indexed JavaScript module paging (#16730)
This commit is contained in:
1 parent
80be901897
commit
f6819749d3
1 file changed
+17
-27
@@ -183,33 +183,23 @@ const modulePage = (
|
||||
return paginateModuleEntries(moduleEntries(analysis.graph.nodes), view);
|
||||
const selectedKind = view.where?.kind;
|
||||
const selectedPath = view.where?.path;
|
||||
if (selectedPath !== undefined && selectedKind === undefined) {
|
||||
const candidates = index.nodesByPath.get(selectedPath) ?? [];
|
||||
const slice = candidates.slice(view.offset, view.offset + view.limit);
|
||||
return {
|
||||
entries:
|
||||
selectedPath === null
|
||||
? slice
|
||||
: slice.map((entry) => ({ ...entry, path: selectedPath })),
|
||||
total: candidates.length,
|
||||
};
|
||||
}
|
||||
if (selectedPath === undefined && selectedKind !== undefined) {
|
||||
const candidates = index.nodesByKind.get(selectedKind) ?? [];
|
||||
return {
|
||||
entries: candidates.slice(view.offset, view.offset + view.limit),
|
||||
total: candidates.length,
|
||||
};
|
||||
}
|
||||
if (selectedPath === undefined && selectedKind === undefined)
|
||||
return {
|
||||
entries: index.moduleEntries.slice(view.offset, view.offset + view.limit),
|
||||
total: index.moduleEntries.length,
|
||||
};
|
||||
return paginateModuleEntries(
|
||||
index.nodesByPath.get(selectedPath!) ?? [],
|
||||
view,
|
||||
);
|
||||
const candidates =
|
||||
selectedPath !== undefined
|
||||
? (index.nodesByPath.get(selectedPath) ?? [])
|
||||
: selectedKind === undefined
|
||||
? index.moduleEntries
|
||||
: (index.nodesByKind.get(selectedKind) ?? []);
|
||||
if (selectedPath !== undefined && selectedKind !== undefined)
|
||||
return paginateModuleEntries(candidates, view);
|
||||
|
||||
const entries = candidates.slice(view.offset, view.offset + view.limit);
|
||||
return {
|
||||
entries:
|
||||
selectedPath == null
|
||||
? entries
|
||||
: entries.map((entry) => ({ ...entry, path: selectedPath })),
|
||||
total: candidates.length,
|
||||
};
|
||||
};
|
||||
|
||||
const exportNames = (node: ApplicationNode): readonly string[] => {
|
||||
|
||||
Reference in new issue
Block a user