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: removed main notebook from subnotebook tree #5543

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
38 changes: 13 additions & 25 deletions apps/web/src/views/notebook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ function SubNotebooks({
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;
Config.set(`${id}:viewState`, treeRef.current.viewState[id]);
Expand Down Expand Up @@ -198,7 +200,16 @@ function SubNotebooks({
});
}, [contextNotes, context]);

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

if (!rootId) return null;
// if (!notebook) return null;
// const { title } = notebook;

return (
<Flex
Expand Down Expand Up @@ -231,7 +242,7 @@ function SubNotebooks({
<Flex sx={{ alignItems: "center" }}>
{isCollapsed ? <ChevronRight size={16} /> : <ChevronDown size={16} />}
<Text variant="subBody" sx={{ fontSize: 11 }}>
NOTEBOOKS
{title}
</Text>
</Flex>
<Flex sx={{ alignItems: "center" }}>
Expand Down Expand Up @@ -296,17 +307,6 @@ function SubNotebooks({
};
},
async getTreeItem(itemId) {
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
.from({ type: "notebook", id: itemId as string }, "notebook")
Expand All @@ -331,18 +331,6 @@ 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;
}

const notebook = notebooks[id];
if (!notebook) return prev;

Expand Down Expand Up @@ -401,7 +389,7 @@ function SubNotebooks({
{children}
</div>
)}
rootItem="root"
rootItem={rootId}
treeLabel="Tree Example"
/>
</UncontrolledTreeEnvironment>
Expand Down
Loading