Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: lookup topic notes at notebook level

ammarahm-ed0a45e963a660
diff --git a/apps/web/src/navigation/routes.jsx b/apps/web/src/navigation/routes.jsx
index ae6d5ee48..4692db244 100644
--- a/apps/web/src/navigation/routes.jsx
+++ b/apps/web/src/navigation/routes.jsx
@@ -65,7 +65,7 @@ const routes = {
return {
key: "notebook",
- type: "notebook",
+ type: "notes",
component: <Topics />,
buttons: {
back: {
diff --git a/apps/web/src/views/search.jsx b/apps/web/src/views/search.jsx
index 7aaefa637..79acdcce2 100644
--- a/apps/web/src/views/search.jsx
+++ b/apps/web/src/views/search.jsx
@@ -41,7 +41,19 @@ async function typeToItems(type, context) {
await db.notes.init();
if (!context) return ["notes", db.notes.all];
const notes = context.notes;
- return ["notes", notes];
+ let topicNotes = [];
+ if (context.type === "notebook") {
+ topicNotes = db.notebooks
+ .notebook(context.value.id)
+ .topics.all.map((topic) => {
+ return db.notes.topicReferences
+ .get(topic.id)
+ .map((id) => db.notes.note(id).data);
+ })
+ .flat()
+ .filter((n) => notes.findIndex((note) => note.id !== n.id) === -1);
+ }
+ return ["notes", [...notes, ...topicNotes]];
}
case "notebooks":
return ["notebooks", db.notebooks.all];
@@ -105,6 +117,10 @@ function Search({ type }) {
const topic = notebook.topics.topic(context.value.topic);
return `notes of ${topic._topic.title} in ${notebook.title}`;
}
+ case "notebook": {
+ const notebook = db.notebooks.notebook(context.value.id);
+ return `notes in ${notebook.title}`;
+ }
case "tag": {
const tag = db.tags.all.find((tag) => tag.id === context.value);
return `notes in #${tag.title}`;