Skip to content

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

refactor: simplify notebooks list profile

thecodrr15c6226ea8a4
diff --git a/apps/web/src/common/list-profiles.js b/apps/web/src/common/list-profiles.js
index 36602b606..81bbc2bde 100644
--- a/apps/web/src/common/list-profiles.js
+++ b/apps/web/src/common/list-profiles.js
@@ -25,22 +25,7 @@ const NotesProfile = createProfile(
);
const NotebooksProfile = createProfile(
- (index, item) => (
- <Notebook
- index={index}
- item={item}
- onClick={() => {
- if (item.topics.length === 1) {
- navigate(`/notebooks/${item.id}/${item.topics[0].id}`);
- } else {
- navigate(`/notebooks/${item.id}`);
- }
- }}
- onTopicClick={(notebook, topic) =>
- navigate(`/notebooks/${notebook.id}/${topic}`)
- }
- />
- ),
+ (index, item) => <Notebook index={index} item={item} />,
getNotebookHeight,
MAX_HEIGHTS.notebook
);
diff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.js
index 4bba3a06c..db6174e25 100644
--- a/apps/web/src/components/notebook/index.js
+++ b/apps/web/src/components/notebook/index.js
@@ -6,7 +6,7 @@ import { store as appStore } from "../../stores/app-store";
import { showItemDeletedToast, showUnpinnedToast } from "../../common/toasts";
import { db } from "../../common/db";
import * as Icon from "../icons";
-import { hashNavigate } from "../../navigation";
+import { hashNavigate, navigate } from "../../navigation";
import { getTotalNotes } from "../../common";
class Notebook extends React.Component {
@@ -15,18 +15,22 @@ class Notebook extends React.Component {
const nextItem = nextProps.item;
return (
prevItem.pinned !== nextItem.pinned ||
- prevItem.favorite !== nextItem.favorite ||
+ prevItem.title !== nextItem.title ||
+ prevItem.description !== nextItem.description ||
prevItem !== nextItem
);
}
render() {
- const { item, index, onClick, onTopicClick } = this.props;
+ const { item, index } = this.props;
const notebook = item;
+
return (
<ListItem
selectable
item={notebook}
- onClick={onClick}
+ onClick={() => {
+ navigate(`/notebooks/${notebook.id}`);
+ }}
title={notebook.title}
body={notebook.description}
index={index}
@@ -38,7 +42,7 @@ class Notebook extends React.Component {
<Flex
key={topic.id}
onClick={(e) => {
- onTopicClick(notebook, topic.id);
+ navigate(`/notebooks/${notebook.id}/${topic.id}`);
e.stopPropagation();
}}
bg="primary"