A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: calculate totalNotes instead of using cached value
thecodrr95def64f459b
diff --git a/apps/web/src/common/index.js b/apps/web/src/common/index.jsindex 71f6a54ba..aa350533f 100644--- a/apps/web/src/common/index.js+++ b/apps/web/src/common/index.js@@ -110,3 +110,9 @@ export function isUserPremium() {subStatus === SUBSCRIPTION_STATUS.TRIAL);}++export function getTotalNotes(notebook) {+ return notebook.topics.reduce((sum, topic) => {+ return sum + topic.notes.length;+ }, 0);+}diff --git a/apps/web/src/components/dialogs/move-note-dialog.js b/apps/web/src/components/dialogs/move-note-dialog.jsindex 117478ed3..a9bfd4a50 100644--- a/apps/web/src/components/dialogs/move-note-dialog.js+++ b/apps/web/src/components/dialogs/move-note-dialog.js@@ -7,6 +7,7 @@ import { showNotesMovedToast } from "../../common/toasts";import { showToast } from "../../utils/toast";import Field from "../field";import { store as notestore } from "../../stores/note-store";+import { getTotalNotes } from "../../common";class MoveDialog extends React.Component {_inputRef;@@ -119,7 +120,7 @@ class MoveDialog extends React.Component {data-test-id={`notebook-${index}`}icon={Icon.Notebook}title={notebook.title}- totalNotes={notebook.totalNotes}+ totalNotes={getTotalNotes(notebook)}onClick={(e) => {this.setState({currentOpenedIndex:@@ -176,7 +177,7 @@ class MoveDialog extends React.Component {indent={1}icon={Icon.Topic}title={topic.title}- totalNotes={topic.totalNotes}+ totalNotes={topic.notes.length}action={this._topicHasNotes(topic, props.noteIds) ? (<Text color="error" fontSize="body">diff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.jsindex 104a887b6..02e00c948 100644--- a/apps/web/src/components/notebook/index.js+++ b/apps/web/src/components/notebook/index.js@@ -7,6 +7,7 @@ import { showItemDeletedToast, showUnpinnedToast } from "../../common/toasts";import { db } from "../../common/db";import * as Icon from "../icons";import { hashNavigate } from "../../navigation";+import { getTotalNotes } from "../../common";class Notebook extends React.Component {shouldComponentUpdate(nextProps) {@@ -64,7 +65,7 @@ class Notebook extends React.Component {<Text as="span" mx={1}>•</Text>- <Text>{notebook.totalNotes} Notes</Text>+ <Text>{getTotalNotes(notebook)} Notes</Text></Flex></>}diff --git a/apps/web/src/components/topic/index.js b/apps/web/src/components/topic/index.jsindex 8a5887070..15ec398b3 100644--- a/apps/web/src/components/topic/index.js+++ b/apps/web/src/components/topic/index.js@@ -16,7 +16,7 @@ function Topic({ item, index, onClick }) {title={topic.title}footer={<Text mt={1} variant="subBody">- {topic.totalNotes} Notes+ {topic.notes.length} Notes</Text>}index={index}@@ -31,7 +31,7 @@ function Topic({ item, index, onClick }) {export default React.memo(Topic, (prev, next) => {return (prev?.item?.title === next?.item?.title &&- prev?.item?.totalNotes === next?.item?.totalNotes+ prev?.item?.notes.length === next?.item?.notes.length);});diff --git a/apps/web/yarn.lock b/apps/web/yarn.lockindex c0748555d..bcbacddeb 100644--- a/apps/web/yarn.lock+++ b/apps/web/yarn.lock@@ -8366,8 +8366,8 @@ normalize-url@^3.0.0:integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg=="notes-core@git+ssh://[email protected]:streetwriters/notesnook-core.git":- version "6.6.2"- resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#8e70cfac7ad5d18c794e148d7e62cf41bef921a5"+ version "6.6.3"+ resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#fdc4038a8d3d83f8248d9ceaf4e8c03ec35429df"dependencies:fast-sort "^2.0.1"fuzzysort "^1.1.4"