diff --git a/apps/web/src/components/icons/index.tsx b/apps/web/src/components/icons/index.tsx index 4b42edd67..be4f2bfa4 100644 --- a/apps/web/src/components/icons/index.tsx +++ b/apps/web/src/components/icons/index.tsx @@ -207,7 +207,8 @@ import { mdiFormTextarea, mdiGavel, mdiDesktopClassic, - mdiBellBadgeOutline + mdiBellBadgeOutline, + mdiDotsHorizontal } from "@mdi/js"; import { useTheme } from "@emotion/react"; import { Theme } from "@notesnook/theme"; @@ -326,6 +327,7 @@ export const Update = createIcon(mdiUpdate); export const Check = createIcon(mdiCheck); export const Cross = createIcon(mdiClose); export const MoreVertical = createIcon(mdiDotsVertical); +export const MoreHorizontal = createIcon(mdiDotsHorizontal); export const Trash = createIcon(mdiTrashCanOutline); export const TopicRemove = createIcon(mdiBookmarkRemoveOutline); export const NotebookRemove = createIcon(mdiBookRemoveOutline); diff --git a/apps/web/src/views/notebook.tsx b/apps/web/src/views/notebook.tsx index 16e971990..2bbcfc8b1 100644 --- a/apps/web/src/views/notebook.tsx +++ b/apps/web/src/views/notebook.tsx @@ -26,8 +26,7 @@ import { ChevronDown, ChevronRight, Edit, - Home, - MoreVertical, + MoreHorizontal, Notebook2, RemoveShortcutLink, ShortcutLink, @@ -225,6 +224,8 @@ function SubNotebooks({ reloadItem.current?.([context.id]); }, [contextNotes, context]); + if (!rootId) return null; + return ( { (async function () { - setCrumbs([ - { title: "Notebooks", id: "notebooks" }, - ...(await db.notebooks.breadcrumbs(context.id)) - ]); + setCrumbs(await db.notebooks.breadcrumbs(context.id)); })(); }, [context.id]); @@ -473,38 +463,51 @@ function NotebookHeader({ return ( + + {crumbs.length > 2 ? ( - + ); + }} + > + + + + ) : null} navigateCrumb(crumb, rootId)} + onClick={() => navigateCrumb(crumb.id, rootId)} > {crumb.title} @@ -588,3 +591,12 @@ function NotebookHeader({ ); } + +function navigateCrumb(notebookId: string, rootId?: string) { + if (notebookId === "notebooks") navigate("/notebooks"); + else if (rootId && notebookId === rootId) { + navigate(`/notebooks/${rootId}`); + } else if (rootId && notebookId) { + navigate(`/notebooks/${rootId}/${notebookId}`); + } +} diff --git a/packages/core/src/collections/notebooks.ts b/packages/core/src/collections/notebooks.ts index 4ab3ffbe9..6ac64000d 100644 --- a/packages/core/src/collections/notebooks.ts +++ b/packages/core/src/collections/notebooks.ts @@ -214,7 +214,11 @@ export class Notebooks implements ICollection { const records = await this.all .fields(["notebooks.id", "notebooks.title"]) .records(ids.map((i) => i.id)); - return ids.reverse().map((id) => records[id.id]) as { + + return ids + .reverse() + .map((id) => records[id.id]) + .filter(Boolean) as { id: string; title: string; }[];