mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-03 12:41:45 +02:00
fix: colors syncing issue (#157)
This commit is contained in:
@@ -9,7 +9,6 @@ import { useStore as useUserStore } from "./stores/user-store";
|
||||
import { useStore as useNotesStore } from "./stores/note-store";
|
||||
import Animated from "./components/animated";
|
||||
import NavigationMenu from "./components/navigationmenu";
|
||||
import { db } from "./common";
|
||||
import { useRoutes } from "hookrouter";
|
||||
import routes from "./navigation/routes";
|
||||
import Editor from "./components/editor";
|
||||
|
||||
@@ -48,7 +48,7 @@ function NavigationMenu(props) {
|
||||
const toggleSideMenu = useAppStore((store) => store.toggleSideMenu);
|
||||
const isSyncing = useUserStore((store) => store.isSyncing);
|
||||
const isLoggedIn = useUserStore((store) => store.isLoggedIn);
|
||||
const logout = useUserStore((store) => store.logout);
|
||||
//const logout = useUserStore((store) => store.logout);
|
||||
const sync = useUserStore((store) => store.sync);
|
||||
const theme = useThemeStore((store) => store.theme);
|
||||
const toggleNightMode = useThemeStore((store) => store.toggleNightMode);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { db, notesFromContext } from "../common/index";
|
||||
import createStore from "../common/store";
|
||||
import { store as editorStore } from "./editor-store";
|
||||
import { store as appStore } from "./app-store";
|
||||
import Vault from "../common/vault";
|
||||
import BaseStore from ".";
|
||||
import { EV } from "notes-core/common";
|
||||
@@ -102,22 +103,10 @@ class NoteStore extends BaseStore {
|
||||
} else {
|
||||
await note.color(color);
|
||||
}
|
||||
this._setValue(id, "colors", db.notes.note(id).data.colors);
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_setValue = (noteId, prop, value) => {
|
||||
this.set((state) => {
|
||||
const { context, notes } = state;
|
||||
const arr = !context ? notes : context.notes;
|
||||
let index = arr.findIndex((note) => note.id === noteId);
|
||||
if (index < 0) return;
|
||||
|
||||
arr[index][prop] = value;
|
||||
this._syncEditor(noteId, prop, value);
|
||||
});
|
||||
if (!this._syncEditor(note.id, "colors", db.notes.note(id).data.colors)) {
|
||||
this.refresh();
|
||||
appStore.refreshColors();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user