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: do not add duplicate attachment
thecodrr21fa4f276285
diff --git a/apps/web/src/components/editor/plugins/picker.js b/apps/web/src/components/editor/plugins/picker.jsindex 0b1a8527e..ceb912743 100644--- a/apps/web/src/components/editor/plugins/picker.js+++ b/apps/web/src/components/editor/plugins/picker.js@@ -85,20 +85,18 @@ async function pickFile(selectedFile) {const { hash, type: hashType } = await fs.hashStream(reader);reader.releaseLock();- let output = {};if (!db.attachments.exists(hash)) {- output = await fs.writeEncryptedFile(selectedFile, key, hash);+ const output = await fs.writeEncryptedFile(selectedFile, key, hash);+ await db.attachments.add({+ ...output,+ hash,+ hashType,+ filename: selectedFile.name,+ type: selectedFile.type,+ key,+ });}- await db.attachments.add({- ...output,- hash,- hashType,- filename: selectedFile.name,- type: selectedFile.type,- key,- });-return {hash: hash,filename: selectedFile.name,@@ -132,20 +130,18 @@ async function pickImage(selectedImage) {const { hash, type: hashType } = await fs.hashStream(reader);reader.releaseLock();- var output = {};if (!db.attachments.exists(hash)) {- output = await fs.writeEncryptedFile(blob, key, hash);+ const output = await fs.writeEncryptedFile(blob, key, hash);+ await db.attachments.add({+ ...output,+ key,+ hash,+ hashType,+ filename: selectedImage.name,+ type: selectedImage.type,+ });}- await db.attachments.add({- ...output,- key,- hash,- hashType,- filename: selectedImage.name,- type: selectedImage.type,- });-return {hash,filename: selectedImage.name,