Skip to content

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

fix: topic preview on note showing incorrect path

thecodrrb18643f5ff62
diff --git a/apps/web/src/common/list-profiles.js b/apps/web/src/common/list-profiles.js
index 6f636702a..b312d659d 100644
--- a/apps/web/src/common/list-profiles.js
+++ b/apps/web/src/common/list-profiles.js
@@ -1,5 +1,4 @@
import { navigate } from "../navigation/";
-import React from "react";
import Note from "../components/note";
import Notebook from "../components/notebook";
import Tag from "../components/tag";
@@ -18,32 +17,16 @@ function createProfile(item, itemHeight, estimatedItemHeight) {
}
const NotesProfile = createProfile(
- (index, item, context) => {
- // TODO doing all this here could be a potential performance issue.
-
- let tags = item.tags;
- if (tags) tags = tags.map((t) => db.tags.tag(t)).slice(0, 3);
- if (context?.type !== "topic" && item.notebooks?.length) {
- const noteNotebook = item.notebooks[0];
- const _notebook = db.notebooks.notebook(noteNotebook.id);
- var notebook = _notebook?.data;
-
- const topicId = noteNotebook.topics[0];
- const topic = _notebook?.topics.topic(topicId);
- notebook.topic = topic?._topic;
- }
-
- return (
- <Note
- index={index}
- pinnable={!context}
- item={item}
- tags={tags || []}
- notebook={notebook}
- context={context}
- />
- );
- },
+ (index, item, context) => (
+ <Note
+ index={index}
+ pinnable={!context}
+ item={item}
+ tags={getTags(item)}
+ notebook={getNotebook(item.notebooks, context?.type)}
+ context={context}
+ />
+ ),
getNoteHeight,
MAX_HEIGHTS.note
);
@@ -90,3 +73,23 @@ const Profiles = {
trash: TrashProfile,
};
export default Profiles;
+
+function getTags(item) {
+ let tags = item.tags;
+ if (tags) tags = tags.map((t) => db.tags.tag(t)).slice(0, 3);
+ return tags || [];
+}
+
+function getNotebook(notebooks, contextType) {
+ if (contextType !== "topic" && notebooks?.length) {
+ const noteNotebook = notebooks[0];
+ const _notebook = db.notebooks.notebook(noteNotebook.id);
+ let notebook = _notebook?.data;
+
+ const topicId = noteNotebook.topics[0];
+ const topic = _notebook?.topics.topic(topicId);
+ notebook.topic = topic?._topic;
+ return notebook;
+ }
+ return;
+}