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
sync: make it work (only upload working)
thecodrrc1e6199cc749
diff --git a/packages/core/api/sync.js b/packages/core/api/sync.jsindex 9bad351cb..2c17dd695 100644--- a/packages/core/api/sync.js+++ b/packages/core/api/sync.js@@ -62,27 +62,30 @@ export default class Sync {}async _merge({ serverResponse, lastSyncedTimestamp, user }) {- const { notes, synced, notebooks } = serverResponse;+ const { notes, synced, notebooks,delta, text } = serverResponse;if (!synced) {- syncArrayWithDatabase(+ await syncArrayWithDatabase(notes,- id => this.db.notes.note(id).data,+ id => this.db.notes.note(id),item => this.db.notes.add(item));- syncArrayWithDatabase(+ await syncArrayWithDatabase(notebooks,- id => this.db.notebooks.notebook(id).data,+ id => this.db.notebooks.notebook(id),item => this.db.notebooks.add(item));- ["delta", "text"].forEach(type => {- syncArrayWithDatabase(- serverResponse[type],- id => this.db[type].raw(id),- item => this.db[type].add(item)+ await syncArrayWithDatabase(+ delta,+ id => this.db.delta.raw(id),+ item => this.db.delta.add(item)+ );+ await syncArrayWithDatabase(+ text,+ id => this.db.text.raw(id),+ item => this.db.text.add(item));- });}// TODO trash, colors, tagsreturn {@@ -130,7 +133,7 @@ async function syncWithDatabase(remoteItem, get, add) {}async function syncArrayWithDatabase(array, get, set) {- array.forEach(async item => await syncWithDatabase(item, get, set));+ return Promise.all(array.map(async item => await syncWithDatabase(item, get, set)));}function prepareForServer(array, user, lastSyncedTimestamp) {diff --git a/packages/core/models/note.js b/packages/core/models/note.jsindex 7a119679c..12759de9d 100644--- a/packages/core/models/note.js+++ b/packages/core/models/note.js@@ -40,6 +40,10 @@ export default class Note {return this._note.notebook;}+ get dateEdited() {+ return this._note.dateEdited;+ }+delta() {return this._notes._deltaCollection.get(this._note.content.delta);}diff --git a/packages/core/models/notebook.js b/packages/core/models/notebook.jsindex 4c286aac5..0fdbf368c 100644--- a/packages/core/models/notebook.js+++ b/packages/core/models/notebook.js@@ -24,6 +24,10 @@ export default class Notebook {return new Topics(this._notebooks, this._notebook.id);}+ get dateEdited() {+ return this._notebook.dateEdited;+ }+_toggle(prop) {return this._notebooks.add({id: this._notebook.id,