From 5cca28daa1404ace23a437b734ebfdbd529175eb Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 21 Apr 2025 09:39:09 +0500 Subject: [PATCH] global: minor refactors --- .../src/components/navigation-menu/index.tsx | 4 ++-- apps/web/src/navigation/routes.tsx | 19 ++++++++++--------- packages/intl/locale/en.po | 6 ++++++ packages/intl/locale/pseudo-LOCALE.po | 6 ++++++ 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/apps/web/src/components/navigation-menu/index.tsx b/apps/web/src/components/navigation-menu/index.tsx index 67c6f8254..1056d733e 100644 --- a/apps/web/src/components/navigation-menu/index.tsx +++ b/apps/web/src/components/navigation-menu/index.tsx @@ -213,9 +213,9 @@ function NavigationMenu({ onExpand }: { onExpand?: () => void }) { }, [isNavPaneCollapsed]); useEffect(() => { - // collapse navigation menu on navigate e.g. when navigating to a notebook - // or a tag function onNavigate() { + // collapse navigation menu on navigate e.g. when navigating to a notebook + // or a tag if (!useAppStore.getState().isNavPaneCollapsed) return; setExpanded(false); } diff --git a/apps/web/src/navigation/routes.tsx b/apps/web/src/navigation/routes.tsx index 01db23154..28a279de6 100644 --- a/apps/web/src/navigation/routes.tsx +++ b/apps/web/src/navigation/routes.tsx @@ -22,7 +22,8 @@ import AllNotes from "../views/all-notes"; import Notes from "../views/notes"; import { NotebookHeader } from "../components/notebook-header"; import Trash from "../views/trash"; -import { store as notestore } from "../stores/note-store"; +import { useStore as useNoteStore } from "../stores/note-store"; +import { useStore as useAppStore } from "../stores/app-store"; import Reminders from "../views/reminders"; import { RouteResult, defineRoutes } from "./types"; import { CREATE_BUTTON_MAP } from "../common"; @@ -39,7 +40,7 @@ const NOT_FOUND_ROUTE = defineRoute({ }); const routes = defineRoutes({ "/notes": () => { - notestore.setContext(); + useNoteStore.getState().setContext(); return defineRoute({ key: "home", type: "notes", @@ -57,7 +58,7 @@ const routes = defineRoutes({ const notebook = await db.notebooks.notebook(notebookId); if (!notebook) return NOT_FOUND_ROUTE; const totalNotes = await db.relations.from(notebook, "note").count(); - notestore.setContext({ + useNoteStore.getState().setContext({ type: "notebook", id: notebookId, item: notebook, @@ -75,7 +76,7 @@ const routes = defineRoutes({ }); }, "/favorites": () => { - notestore.setContext({ type: "favorite" }); + useNoteStore.getState().setContext({ type: "favorite" }); return defineRoute({ key: "notes", title: strings.routes.Favorites(), @@ -84,7 +85,7 @@ const routes = defineRoutes({ }); }, "/reminders": () => { - notestore.setContext(); + useNoteStore.getState().setContext(); return defineRoute({ key: "reminders", title: strings.routes.Reminders(), @@ -96,7 +97,7 @@ const routes = defineRoutes({ }); }, "/trash": () => { - notestore.setContext(); + useNoteStore.getState().setContext(); return defineRoute({ key: "trash", type: "trash", @@ -107,7 +108,7 @@ const routes = defineRoutes({ "/tags/:tagId": async ({ tagId }) => { const tag = await db.tags.tag(tagId); if (!tag) return NOT_FOUND_ROUTE; - notestore.setContext({ type: "tag", id: tagId }); + useNoteStore.getState().setContext({ type: "tag", id: tagId }); return defineRoute({ key: "notes", type: "notes", @@ -118,7 +119,7 @@ const routes = defineRoutes({ "/colors/:colorId": async ({ colorId }) => { const color = await db.colors.color(colorId); if (!color) return NOT_FOUND_ROUTE; - notestore.setContext({ type: "color", id: colorId }); + useNoteStore.getState().setContext({ type: "color", id: colorId }); return defineRoute({ key: "notes", type: "notes", @@ -127,7 +128,7 @@ const routes = defineRoutes({ }); }, "/monographs": () => { - notestore.setContext({ type: "monographs" }); + useNoteStore.getState().setContext({ type: "monographs" }); return defineRoute({ key: "notes", title: strings.routes.Monographs(), diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po index 887fd8e2d..4e64d916b 100644 --- a/packages/intl/locale/en.po +++ b/packages/intl/locale/en.po @@ -6,6 +6,12 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "X-Generator: @lingui/cli\n" "Language: en\n" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" +"Plural-Forms: \n" #: src/strings.ts:2394 msgid " \"Notebook > Notes\"" diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po index d9fa080ea..3f47f42a3 100644 --- a/packages/intl/locale/pseudo-LOCALE.po +++ b/packages/intl/locale/pseudo-LOCALE.po @@ -6,6 +6,12 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "X-Generator: @lingui/cli\n" "Language: pseudo-LOCALE\n" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" +"Plural-Forms: \n" #: src/strings.ts:2394 msgid " \"Notebook > Notes\""