A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: backend data structure changes
thecodrr37dbc7f4f4e8
diff --git a/packages/core/api/sync/__tests__/sync.test.js b/packages/core/api/sync/__tests__/sync.test.jsindex 1516d0088..1dabf3fb1 100644--- a/packages/core/api/sync/__tests__/sync.test.js+++ b/packages/core/api/sync/__tests__/sync.test.js@@ -35,7 +35,7 @@ test("sync without merge conflicts, cause merge conflicts, resolve them and thenawait db.sync();const user = await db.user.get();- expect(user.lastSynced).toBeGreaterThan(0);+ expect(user.notesnook.lastSynced).toBeGreaterThan(0);/////// CAUSE MERGE CONFLICT! ///////// 4. edit the note's contentdiff --git a/packages/core/api/sync/__tests__/utils.js b/packages/core/api/sync/__tests__/utils.jsindex 74f9c005d..b9531ee37 100644--- a/packages/core/api/sync/__tests__/utils.js+++ b/packages/core/api/sync/__tests__/utils.js@@ -7,7 +7,9 @@ const SUCCESS_LOGIN_RESPONSE = {payload: {username: "thecodrr",email: process.env.EMAIL,- lastSynced: 0,+ notesnook: {+ lastSynced: 0,+ },},scopes: "sync",expiry: 36000,diff --git a/packages/core/api/sync/index.js b/packages/core/api/sync/index.jsindex 81514fb37..7b3964b42 100644--- a/packages/core/api/sync/index.js+++ b/packages/core/api/sync/index.js@@ -61,7 +61,7 @@ export default class Sync {await this._db.conflicts.recalculate();await this._db.conflicts.check();- let lastSynced = user.lastSynced || 0;+ let lastSynced = user.notesnook.lastSynced || 0;let serverResponse = await this._fetch(lastSynced, token);// we prepare local data before merging so we always have correct data@@ -77,7 +77,9 @@ export default class Sync {lastSynced = await this._send(data, token);// update our lastSynced time- if (lastSynced) await this._db.user.set({ lastSynced });+ if (lastSynced) {+ await this._db.user.set({ notesnook: { ...user.notesnook, lastSynced } });+ }}async _send(data, token) {diff --git a/packages/core/models/user.js b/packages/core/models/user.jsindex db4741750..e9045194e 100644--- a/packages/core/models/user.js+++ b/packages/core/models/user.js@@ -17,9 +17,8 @@ export default class User {user = await authRequest.call(this, "users", undefined, true, true);if (!user) return await this.clear();} catch (e) {- return await this.clear();+ return await this._context.clear();}- delete user.lastSynced;await this.set(user);}@@ -54,10 +53,6 @@ export default class User {await this._context.write("user", user);}- async clear() {- await this._context.write("user", {});- }-async login(username, password) {let response = await authRequest("oauth/token", {username,