fix: colors syncing issue (#157)

This commit is contained in:
thecodrr
2020-11-02 15:57:53 +05:00
parent 371e7c91e5
commit 0f89ae1af6
3 changed files with 6 additions and 18 deletions

View File

@@ -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";

View File

@@ -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);

View File

@@ -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();
}
};
/**