mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-25 16:09:42 +01:00
fix: calculate totalNotes instead of using cached value
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
</>
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -8366,8 +8366,8 @@ normalize-url@^3.0.0:
|
||||
integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg==
|
||||
|
||||
"notes-core@git+ssh://git@github.com:streetwriters/notesnook-core.git":
|
||||
version "6.6.2"
|
||||
resolved "git+ssh://git@github.com:streetwriters/notesnook-core.git#8e70cfac7ad5d18c794e148d7e62cf41bef921a5"
|
||||
version "6.6.3"
|
||||
resolved "git+ssh://git@github.com:streetwriters/notesnook-core.git#fdc4038a8d3d83f8248d9ceaf4e8c03ec35429df"
|
||||
dependencies:
|
||||
fast-sort "^2.0.1"
|
||||
fuzzysort "^1.1.4"
|
||||
|
||||
Reference in New Issue
Block a user