Skip to content

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

fix: total notes don't update on notebook items

thecodrr90d9398c9bab
diff --git a/apps/web/src/common/list-profiles.js b/apps/web/src/common/list-profiles.js
index 156c2e25f..b77b1be21 100644
--- a/apps/web/src/common/list-profiles.js
+++ b/apps/web/src/common/list-profiles.js
@@ -11,6 +11,7 @@ import {
MAX_HEIGHTS,
} from "./height-calculator";
import { db } from "./db";
+import { getTotalNotes } from ".";
function createProfile(item, itemHeight, estimatedItemHeight) {
return { item, itemHeight, estimatedItemHeight };
@@ -32,7 +33,9 @@ const NotesProfile = createProfile(
);
const NotebooksProfile = createProfile(
- (index, item) => <Notebook index={index} item={item} />,
+ (index, item) => (
+ <Notebook index={index} item={item} totalNotes={getTotalNotes(item)} />
+ ),
getNotebookHeight,
MAX_HEIGHTS.notebook
);
diff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.js
index d7023c996..96f2eb226 100644
--- a/apps/web/src/components/notebook/index.js
+++ b/apps/web/src/components/notebook/index.js
@@ -7,12 +7,11 @@ import { showItemDeletedToast, showUnpinnedToast } from "../../common/toasts";
import { db } from "../../common/db";
import * as Icon from "../icons";
import { hashNavigate, navigate } from "../../navigation";
-import { getTotalNotes } from "../../common";
import IconTag from "../icon-tag";
import { showToast } from "../../utils/toast";
function Notebook(props) {
- const { item, index } = props;
+ const { item, index, totalNotes } = props;
const notebook = item;
const isCompact = useStore((store) => store.viewMode === "compact");
@@ -32,7 +31,7 @@ function Notebook(props) {
isCompact ? (
<>
<Text fontSize="subBody" color="fontTertiary">
- {getTotalNotes(notebook)} Notes
+ {totalNotes} {totalNotes > 1 ? "notes" : "note"}
</Text>
</>
) : (
@@ -72,7 +71,9 @@ function Notebook(props) {
<Text as="span" mx={1}>
•
</Text>
- <Text>{getTotalNotes(notebook)} Notes</Text>
+ <Text>
+ {totalNotes} {totalNotes > 1 ? "notes" : "note"}
+ </Text>
</Flex>
</>
)
@@ -83,11 +84,13 @@ function Notebook(props) {
export default React.memo(Notebook, (prev, next) => {
const prevItem = prev.item;
const nextItem = next.item;
+
return (
prevItem.pinned === nextItem.pinned &&
prevItem.title === nextItem.title &&
prevItem.description === nextItem.description &&
- prevItem.topics.length === nextItem.topics.length
+ prevItem.topics.length === nextItem.topics.length &&
+ prev.totalNotes === next.totalNotes
);
});
diff --git a/apps/web/src/views/topics.js b/apps/web/src/views/topics.js
index e64b686fa..00ad02bdc 100644
--- a/apps/web/src/views/topics.js
+++ b/apps/web/src/views/topics.js
@@ -49,6 +49,7 @@ function NotebookHeader({ notebook }) {
useEffect(() => {
setIsShortcut(menuPins.findIndex((p) => p.id === notebook.id) > -1);
}, [menuPins, notebook]);
+ const totalNotes = getTotalNotes(notebook);
return (
<Flex flexDirection="column" mx={2} my={2}>
@@ -92,8 +93,8 @@ function NotebookHeader({ notebook }) {
</Text>
)}
<Text as="em" variant="subBody" mt={2}>
- {topics.length} {topics.length > 1 ? "topics" : "topic"},{" "}
- {getTotalNotes(notebook)} {topics.length > 1 ? "notes" : "note"}
+ {topics.length} {topics.length > 1 ? "topics" : "topic"}, {totalNotes}{" "}
+ {totalNotes > 1 ? "notes" : "note"}
</Text>
</Flex>
);