mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-03 04:31:46 +02:00
fix: crash on notebooks & other related views
(fixes streetwriters/notesnook#504, streetwriters/notesnook#512, streetwriters/notesnook#513)
This commit is contained in:
@@ -9,6 +9,7 @@ import { store as notestore } from "../../stores/note-store";
|
||||
import { useStore, store } from "../../stores/notebook-store";
|
||||
import { getTotalNotes } from "../../common";
|
||||
import Accordion from "../accordion";
|
||||
import { pluralize } from "../../utils/string";
|
||||
|
||||
function MoveDialog({ onClose, noteIds }) {
|
||||
const [selected, setSelected] = useState([]);
|
||||
@@ -139,7 +140,7 @@ function MoveDialog({ onClose, noteIds }) {
|
||||
indent={1}
|
||||
icon={Icon.Topic}
|
||||
title={topic.title}
|
||||
totalNotes={topic.notes.length}
|
||||
totalNotes={topic.notes?.length || 0}
|
||||
action={
|
||||
isSelected && hasNotes ? (
|
||||
<Icon.Close
|
||||
@@ -175,7 +176,7 @@ function MoveDialog({ onClose, noteIds }) {
|
||||
}
|
||||
|
||||
function topicHasNotes(topic, noteIds) {
|
||||
return noteIds.some((id) => topic.notes.indexOf(id) > -1);
|
||||
return noteIds.some((id) => topic.notes && topic.notes.indexOf(id) > -1);
|
||||
}
|
||||
|
||||
function FilteredList({
|
||||
@@ -292,7 +293,7 @@ function Item(props) {
|
||||
>
|
||||
<Flex flexDirection="column">
|
||||
<Text variant="body">{title}</Text>
|
||||
<Text variant="subBody">{totalNotes + " notes"}</Text>
|
||||
<Text variant="subBody">{pluralize(totalNotes, "note", "notes")}</Text>
|
||||
</Flex>
|
||||
{action}
|
||||
</Button>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import React from "react";
|
||||
import ListItem from "../list-item";
|
||||
import { db } from "../../common/db";
|
||||
import { store } from "../../stores/notebook-store";
|
||||
import { store as appStore } from "../../stores/app-store";
|
||||
import { hashNavigate } from "../../navigation";
|
||||
import { Flex, Text } from "rebass";
|
||||
@@ -29,7 +28,7 @@ function Topic({ item, index, onClick }) {
|
||||
•
|
||||
</Text>
|
||||
<Text variant="subBody">
|
||||
{pluralize(topic.notes.length, "note", "notes")}
|
||||
{pluralize(topic.notes?.length || 0, "note", "notes")}
|
||||
</Text>
|
||||
</Flex>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user