Skip to content

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

fix: topics on all notes are wrong (fixes streetwriters/notesnook#187)

thecodrr479ffe892665
diff --git a/apps/web/src/common/list-profiles.js b/apps/web/src/common/list-profiles.js
index b77b1be21..ff63ee793 100644
--- a/apps/web/src/common/list-profiles.js
+++ b/apps/web/src/common/list-profiles.js
@@ -89,15 +89,21 @@ function getTags(item) {
}
function getNotebook(notebooks, contextType) {
- if (contextType !== "topic" && notebooks?.length) {
- const noteNotebook = notebooks[0];
- const _notebook = db.notebooks.notebook(noteNotebook.id);
- let notebook = _notebook?.data;
+ if (contextType === "topic" || !notebooks?.length) return;
- const topicId = noteNotebook.topics[0];
- const topic = _notebook?.topics.topic(topicId);
- notebook.topic = topic?._topic;
- return notebook;
- }
- return;
+ const noteNotebook = notebooks[0];
+ const topicId = noteNotebook.topics[0];
+
+ const notebook = db.notebooks.notebook(noteNotebook.id)?.data;
+ if (!notebook) return;
+
+ const topic = notebook.topics.find((t) => t.id === topicId);
+ if (!topic) return;
+
+ return {
+ id: notebook.id,
+ title: notebook.title,
+ dateEdited: notebook.dateEdited,
+ topic: { id: topicId, title: topic.title },
+ };
}
diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.js
index a0827e148..c47049283 100644
--- a/apps/web/src/components/note/index.js
+++ b/apps/web/src/components/note/index.js
@@ -174,7 +174,7 @@ export default React.memo(Note, function (prevProps, nextProps) {
prevItem.locked === nextItem.locked &&
prevItem.conflicted === nextItem.conflicted &&
prevItem.color === nextItem.color &&
- JSON.stringify(prevProps.notebook) === JSON.stringify(nextProps.notebook) &&
+ prevProps.notebook?.dateEdited === nextProps.notebook?.dateEdited &&
JSON.stringify(prevProps.tags) === JSON.stringify(nextProps.tags)
);
});