Skip to content

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

fix: properly migrate from note.colors to note.color

thecodrrbf5eff4cb746
diff --git a/apps/web/src/components/menu/colors.js b/apps/web/src/components/menu/colors.js
index 784e1622d..d23198a39 100644
--- a/apps/web/src/components/menu/colors.js
+++ b/apps/web/src/components/menu/colors.js
@@ -7,7 +7,7 @@ import { Flex } from "rebass";
import useMobile from "../../utils/use-mobile";
function Colors(props) {
- const { id, colors } = props.data;
+ const { id, color } = props.data;
const setColor = useStore((store) => store.setColor);
const isMobile = useMobile();
return (
@@ -27,7 +27,7 @@ function Colors(props) {
strokeWidth={0}
data-test-id={`menuitem-colors-${label}`}
/>
- {colors.includes(label) && (
+ {color === label && (
<Icon.Checkmark
data-test-id={`menuitem-colors-${label}-check`}
sx={{
diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.js
index 5af812538..9967e02ca 100644
--- a/apps/web/src/components/note/index.js
+++ b/apps/web/src/components/note/index.js
@@ -221,6 +221,6 @@ export default React.memo(Note, function (prevProps, nextProps) {
prevItem.title === nextItem.title &&
prevItem.locked === nextItem.locked &&
prevItem.conflicted === nextItem.conflicted &&
- JSON.stringify(prevItem.colors) === JSON.stringify(nextItem.colors)
+ prevItem.color === nextItem.color
);
});
diff --git a/apps/web/src/components/properties/index.js b/apps/web/src/components/properties/index.js
index 12a92208a..756072d7b 100644
--- a/apps/web/src/components/properties/index.js
+++ b/apps/web/src/components/properties/index.js
@@ -24,7 +24,7 @@ const tools = [
function Properties() {
const [notebook, setNotebook] = useState();
- const colors = useStore((store) => store.session.colors);
+ const color = useStore((store) => store.session.color);
const toggleLocked = useStore((store) => store.toggleLocked);
const tags = useStore((store) => store.session.tags);
const sessionId = useStore((store) => store.session.id);
@@ -178,7 +178,7 @@ function Properties() {
{toTitleCase(label)}
</Text>
</Flex>
- {colors.includes(label) && (
+ {color === label && (
<Icon.Checkmark
color="primary"
size={20}
diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.js
index be111883f..9b04f9512 100644
--- a/apps/web/src/stores/editor-store.js
+++ b/apps/web/src/stores/editor-store.js
@@ -19,7 +19,7 @@ const DEFAULT_SESSION = {
locked: false,
tags: [],
context: undefined,
- colors: [],
+ color: undefined,
dateEdited: 0,
totalWords: 0,
content: {
@@ -104,7 +104,7 @@ class EditorStore extends BaseStore {
if (oldSession.tags.length !== this.get().session.tags.length)
tagStore.refresh();
- if (oldSession.colors.length !== this.get().session.colors.length)
+ if (oldSession.color !== this.get().session.color)
appStore.refreshColors();
if (!oldSession.context) break storeSync;
diff --git a/apps/web/src/stores/note-store.js b/apps/web/src/stores/note-store.js
index 896de624b..482f19993 100644
--- a/apps/web/src/stores/note-store.js
+++ b/apps/web/src/stores/note-store.js
@@ -112,13 +112,10 @@ class NoteStore extends BaseStore {
setColor = async (id, color) => {
let note = db.notes.note(id);
if (!note) return;
- const shouldUncolor = note.data.colors.indexOf(color) > -1;
- for (var c of note.data.colors) {
- await note.uncolor(c);
- }
+ const shouldUncolor = note.data.color === color;
if (!shouldUncolor) await db.notes.note(id).color(color);
appStore.refreshColors();
- if (!this._syncEditor(note.id, "colors", db.notes.note(id).data.colors)) {
+ if (!this._syncEditor(note.id, "color", db.notes.note(id).data.color)) {
this.refresh();
}
};
diff --git a/apps/web/yarn.lock b/apps/web/yarn.lock
index b73eaf497..22fe1a5ad 100644
--- a/apps/web/yarn.lock
+++ b/apps/web/yarn.lock
@@ -8962,9 +8962,21 @@ normalize-url@^3.0.0, normalize-url@^3.0.1:
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-3.3.0.tgz#b2e1c4dc4f7c6d57743df733a4f5978d18650559"
integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg==
+notes-core@../notes-core/:
+ version "4.0.0"
+ dependencies:
+ fast-sort "^2.0.1"
+ fuzzysearch "^1.0.3"
+ jshashes "^1.0.8"
+ no-internet "^1.5.2"
+ qclone "^1.0.4"
+ quill-delta-to-html "^0.12.0"
+ quill-delta-to-markdown "https://github.com/streetwriters/quill-delta-to-markdown"
+ transfun "^1.0.2"
+
"notes-core@git+ssh://[email protected]:streetwriters/notesnook-core.git":
version "4.0.0"
- resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#202bfdcc24c347455857c0a8b5e804df68a8b9e2"
+ resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#1692099ea401ec66ec6ff7d445c730915eb8b800"
dependencies:
fast-sort "^2.0.1"
fuzzysearch "^1.0.3"