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

web: fix confusing nested display #6011

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
57 changes: 32 additions & 25 deletions apps/web/src/views/notebook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ function SubNotebooks({
const notebooks = useNotebookStore((store) => store.notebooks);
const contextNotes = useNotesStore((store) => store.contextNotes);
const context = useNotesStore((store) => store.context);
const [title, setTitle] = useState<string>();

const saveViewState = useCallback((id: string) => {
if (!treeRef.current?.viewState) return;
Expand Down Expand Up @@ -198,8 +199,15 @@ function SubNotebooks({
});
}, [contextNotes, context]);

if (!rootId) return null;
useEffect(() => {
(async function () {
const notebook = await db.notebooks.notebook(rootId);
if (!notebook) return;
setTitle(notebook.title);
})();
});

if (!rootId) return null;
return (
<Flex
id="subnotebooks"
Expand Down Expand Up @@ -231,7 +239,7 @@ function SubNotebooks({
<Flex sx={{ alignItems: "center" }}>
{isCollapsed ? <ChevronRight size={16} /> : <ChevronDown size={16} />}
<Text variant="subBody" sx={{ fontSize: 11 }}>
NOTEBOOKS
{title?.toUpperCase()}
</Text>
</Flex>
<Flex sx={{ alignItems: "center" }}>
Expand Down Expand Up @@ -269,7 +277,6 @@ function SubNotebooks({
</Button>
</Flex>
</Flex>

<FlexScrollContainer>
<UncontrolledTreeEnvironment
ref={treeRef}
Expand All @@ -296,16 +303,16 @@ function SubNotebooks({
};
},
async getTreeItem(itemId) {
if (itemId === "root") {
return {
data: { notebook: { title: "Root" } },
index: itemId,
isFolder: true,
canMove: false,
canRename: false,
children: [rootId]
};
}
// if (itemId === "root") {
// return {
// data: { notebook: { title: "Root" } },
// index: itemId,
// isFolder: true,
// canMove: false,
// canRename: false,
// children: [rootId]
// };
// }

const notebook = (await db.notebooks.notebook(itemId as string))!;
const children = await db.relations
Expand All @@ -331,17 +338,17 @@ function SubNotebooks({
.get();

return itemIds.reduce((prev, id) => {
if (id === "root") {
prev.push({
data: { notebook: { title: "Root" } },
index: id,
isFolder: true,
canMove: false,
canRename: false,
children: [rootId]
});
return prev;
}
// if (id === "root") {
// prev.push({
// data: { notebook: { title: "Root" } },
// index: id,
// isFolder: true,
// canMove: false,
// canRename: false,
// children: [rootId]
// });
// return prev;
// }

const notebook = notebooks[id];
if (!notebook) return prev;
Expand Down Expand Up @@ -401,7 +408,7 @@ function SubNotebooks({
{children}
</div>
)}
rootItem="root"
rootItem={rootId}
treeLabel="Tree Example"
/>
</UncontrolledTreeEnvironment>
Expand Down