mobile: fix note with attachments not saved from share extension

This commit is contained in:
Ammar Ahmed
2024-03-12 11:48:43 +05:00
parent 2250299608
commit b7d72437de
3 changed files with 5 additions and 6 deletions

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
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";

View File

@@ -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 = `<p><span data-hash="${hash}" data-mime="${file.type}" data-filename="${file.name}" data-size="${file.size}" /></p>`;
}
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: {

View File

@@ -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;