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
fix: content is lost on restoring note
thecodrr99acc7fd38ff
diff --git a/packages/core/api/index.js b/packages/core/api/index.jsindex 36539f136..8520e8dff 100644--- a/packages/core/api/index.js+++ b/packages/core/api/index.js@@ -34,7 +34,7 @@ class Database {this.text);await this.notebooks.init(this.notes, this.trash);- await this.trash.init(this.notes, this.notebooks, this.delta);+ await this.trash.init(this.notes, this.notebooks, this.delta, this.text);this.syncer = new Sync(this);this.vault = new Vault(this, this.context);this.lookup = new Lookup(this);diff --git a/packages/core/api/lookup.js b/packages/core/api/lookup.jsindex 85e926db8..ea6209d75 100644--- a/packages/core/api/lookup.js+++ b/packages/core/api/lookup.js@@ -18,6 +18,7 @@ export default class Lookup {async notes(array, query) {const textIds = array.map(v => v.content.text);const textArray = await this._db.text.multi(textIds);+ console.log(textArray, textIds);const filteredText = tfun.filter(text => fuzzysearch(query, text.data))(textArray);diff --git a/packages/core/collections/notes.js b/packages/core/collections/notes.jsindex 7565dc56d..72ffcab59 100644--- a/packages/core/collections/notes.js+++ b/packages/core/collections/notes.js@@ -1,6 +1,6 @@import CachedCollection from "../database/cached-collection";import fuzzysearch from "fuzzysearch";-import { groupBy } from "../utils";+import { groupBy, isHex } from "../utils";import sort from "fast-sort";import {getWeekGroupFromTimestamp,@@ -46,9 +46,8 @@ export default class Notes {async add(noteArg) {if (!noteArg) return;- if (noteArg.remote){- await this._collection.addItem(noteArg);- return;+ if (noteArg.remote) {+ return await this._collection.addItem(noteArg);}let id = noteArg.id || getId();@@ -71,19 +70,24 @@ export default class Notes {return;}- if (note.content.delta && note.content.delta.ops) {+ const { text, delta } = note.content;++ if (!textId && isHex(text)) textId = text;+ if (!deltaId && isHex(delta)) deltaId = delta;++ if (delta && delta.ops) {deltaId = await this._deltaCollection.add({noteId: id,id: deltaId,- data: note.content.delta+ data: delta});}- if (note.content.text !== textId) {+ if (text !== textId) {textId = await this._textCollection.add({noteId: id,id: textId,- data: note.content.text+ data: text});note.title = getNoteTitle(note);note.headline = getNoteHeadline(note);diff --git a/packages/core/utils/index.js b/packages/core/utils/index.jsindex 76b8e7fed..bd7400234 100644--- a/packages/core/utils/index.js+++ b/packages/core/utils/index.js@@ -67,3 +67,9 @@ function groupBySpecial(arr, key) {g.groups.splice(0, 0, { title: "Pinned" });return g;}++var hexPattern = /([A-F]|[a-f]|\d)*/;+export function isHex(input) {+ if (!input.match || input.length < 16) return false;+ return input.match(hexPattern)[0] === input;+}