Skip to content

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

feat: add automatic syncing

thecodrrc9ac5a98dfb0
diff --git a/apps/web/src/app.js b/apps/web/src/app.js
index f2dfa8f61..e3e69fc05 100644
--- a/apps/web/src/app.js
+++ b/apps/web/src/app.js
@@ -19,7 +19,7 @@ import {
shouldAddBackupReminder,
shouldAddSignupReminder,
} from "./common/reminders";
-import { showRecoveryKeyDialog } from "./components/dialogs/recoverykeydialog";
+import { EV } from "notes-core/common";
function App() {
const [show, setShow] = usePersistentState("isContainerVisible", true);
@@ -71,7 +71,7 @@ function App() {
useEffect(() => {
return () => {
- db.ev.unsubscribeAll();
+ EV.unsubscribeAll();
};
}, []);
diff --git a/apps/web/src/stores/note-store.js b/apps/web/src/stores/note-store.js
index 34ebd0b8e..1f5873518 100644
--- a/apps/web/src/stores/note-store.js
+++ b/apps/web/src/stores/note-store.js
@@ -3,6 +3,7 @@ import createStore from "../common/store";
import { store as editorStore } from "./editor-store";
import Vault from "../common/vault";
import BaseStore from ".";
+import { EV } from "notes-core/common";
class NoteStore extends BaseStore {
notes = [];
@@ -10,7 +11,7 @@ class NoteStore extends BaseStore {
selectedNote = 0;
init = async () => {
- db.ev.subscribe("notes:removeEmptyNote", (id) => {
+ EV.subscribe("notes:removeEmptyNote", (id) => {
const { session, newSession } = editorStore.get();
if (session.id === id) {
newSession();
diff --git a/apps/web/src/stores/user-store.js b/apps/web/src/stores/user-store.js
index 05044cf07..33e89d79d 100644
--- a/apps/web/src/stores/user-store.js
+++ b/apps/web/src/stores/user-store.js
@@ -3,6 +3,7 @@ import { db } from "../common";
import { store as appStore } from "./app-store";
import BaseStore from "./index";
import config from "../utils/config";
+import { EV } from "notes-core/common";
class UserStore extends BaseStore {
isLoggedIn = false;
@@ -18,8 +19,8 @@ class UserStore extends BaseStore {
state.user = user;
state.isLoggedIn = true;
});
- db.ev.subscribe("db:refresh", () => appStore.refresh());
- db.ev.subscribe("user:upgraded", (subscription) => {
+ EV.subscribe("db:refresh", () => appStore.refresh());
+ EV.subscribe("user:upgraded", (subscription) => {
this.set((state) => {
state.user = {
...state.user,
@@ -27,6 +28,7 @@ class UserStore extends BaseStore {
};
});
});
+ EV.subscribe("db:sync", this.sync);
this.sync();
return true;
});
@@ -58,7 +60,8 @@ class UserStore extends BaseStore {
sync = () => {
this.set((state) => (state.isSyncing = true));
- db.sync()
+ return db
+ .sync()
.then(() => {
appStore.refresh();
})
diff --git a/apps/web/yarn.lock b/apps/web/yarn.lock
index cec3e8ff3..1d52b5a17 100644
--- a/apps/web/yarn.lock
+++ b/apps/web/yarn.lock
@@ -8861,7 +8861,7 @@ normalize-url@^3.0.0, normalize-url@^3.0.1:
"notes-core@git+ssh://[email protected]:streetwriters/notesnook-core.git":
version "1.5.0"
- resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#7f3dfbaf4871a195ab81b61e83c37846cc6178ed"
+ resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#abeb8f7a5a4ae52cb6409d930e13238b96941e6f"
dependencies:
fast-sort "^2.0.1"
fuzzysearch "^1.0.3"