From b7d72437deb60cc132bd06de43b5161d0d731a3f Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Tue, 12 Mar 2024 11:48:43 +0500 Subject: [PATCH] mobile: fix note with attachments not saved from share extension --- apps/mobile/app/app.tsx | 2 -- apps/mobile/app/utils/note-bundle.js | 8 ++++---- apps/mobile/native/globals.js | 1 + 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/mobile/app/app.tsx b/apps/mobile/app/app.tsx index a6421b2ba..501b875c5 100644 --- a/apps/mobile/app/app.tsx +++ b/apps/mobile/app/app.tsx @@ -16,7 +16,6 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ -import "@azure/core-asynciterator-polyfill"; import "react-native-gesture-handler"; import { THEME_COMPATIBILITY_VERSION, @@ -24,7 +23,6 @@ import { } from "@notesnook/theme"; import React, { useEffect } from "react"; import { I18nManager, View } from "react-native"; -import "react-native-gesture-handler"; import { GestureHandlerRootView } from "react-native-gesture-handler"; import { SafeAreaProvider } from "react-native-safe-area-context"; import AppLockedOverlay from "./components/app-lock-overlay"; diff --git a/apps/mobile/app/utils/note-bundle.js b/apps/mobile/app/utils/note-bundle.js index bed9596b3..40deb66b1 100644 --- a/apps/mobile/app/utils/note-bundle.js +++ b/apps/mobile/app/utils/note-bundle.js @@ -33,7 +33,7 @@ const santizeUri = (uri) => { export async function attachFile(uri, hash, type, filename, options) { try { - let exists = db.attachments.exists(hash); + let exists = await db.attachments.exists(hash); let encryptionInfo; if (options?.hash && options.hash !== hash) return false; @@ -50,6 +50,7 @@ export async function attachFile(uri, hash, type, filename, options) { encryptionInfo.alg = "xcha-stream"; encryptionInfo.size = encryptionInfo.length; encryptionInfo.key = key; + console.log(encryptionInfo); if (options?.reupload && exists) await db.attachments.reset(hash); } else { encryptionInfo = { hash: hash }; @@ -126,9 +127,8 @@ async function createNotes(bundle) { } else { content = `

`; } - const rawContent = await db.content.raw( - db.notes.note(id).data?.contentId - ); + const note = await db.notes.note(id); + const rawContent = await db.content.get(note?.contentId); await db.notes.add({ id: id, content: { diff --git a/apps/mobile/native/globals.js b/apps/mobile/native/globals.js index 9374e095c..c1e51a395 100644 --- a/apps/mobile/native/globals.js +++ b/apps/mobile/native/globals.js @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-var-requires */ +import "@azure/core-asynciterator-polyfill"; import 'react-native-url-polyfill/auto'; import "./polyfills/console-time.js" global.Buffer = require('buffer').Buffer;