fix: color notebook/topic to which the note is already assigned

(fixes streetwriters/notesnook#567)
This commit is contained in:
thecodrr
2022-06-06 10:35:23 +05:00
parent 3f12d7d149
commit 8469ad8d02

View File

@@ -77,13 +77,21 @@ function MoveDialog({ onClose, noteIds }) {
itemName="notebook"
renderItem={(notebook, index) => {
const selectedTopics = selected.filter((s) => s.id === notebook.id);
const hasNotes = notebook.topics.some((topic) =>
topicHasNotes(topic, noteIds)
);
return (
<Accordion
key={notebook.id}
testId={`notebook-${index}`}
title={
<Flex flexDirection={"column"} sx={{ px: 1 }}>
<Text variant={"body"}>{notebook.title}</Text>
<Text
variant={"body"}
sx={{ color: hasNotes ? "primary" : "text" }}
>
{notebook.title}
</Text>
<Text variant={"subBody"} fontWeight="normal">
{getTotalNotes(notebook)} notes &amp;{" "}
{notebook.topics.length} topics{" "}
@@ -139,7 +147,15 @@ function MoveDialog({ onClose, noteIds }) {
}}
indent={1}
icon={Icon.Topic}
title={topic.title}
title={
hasNotes ? (
<Text as="span" sx={{ color: "primary" }}>
{topic.title}
</Text>
) : (
topic.title
)
}
totalNotes={topic.notes?.length || 0}
action={
isSelected && hasNotes ? (