Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: add logging when loading attachments

Ammar Ahmed3dd8e20e9a7a
diff --git a/apps/mobile/app/common/filesystem/download-attachment.js b/apps/mobile/app/common/filesystem/download-attachment.js
index 1f0455e5b..d5057e735 100644
--- a/apps/mobile/app/common/filesystem/download-attachment.js
+++ b/apps/mobile/app/common/filesystem/download-attachment.js
@@ -218,12 +218,7 @@ export default async function downloadAttachment(
}
if (options.base64 || options.text) {
- console.log(
- "starting decrypt base64 file...",
- options.base64,
- options.text,
- attachment.hash
- );
+ DatabaseLogger.log(`Starting to decrypt... hash: ${attachment.hash}`);
return await db.attachments.read(
attachment.hash,
options.base64 ? "base64" : "text"
@@ -292,7 +287,7 @@ export default async function downloadAttachment(
return fileUri;
} catch (e) {
- console.log("download attachment error: ", e);
+ DatabaseLogger.error(e);
if (attachment.dateUploaded) {
RNFetchBlob.fs
.unlink(RNFetchBlob.fs.dirs.CacheDir + `/${attachment.hash}`)
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsx b/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsx
index da3cae595..224903034 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsx
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsx
@@ -77,7 +77,6 @@ import { EditorMessage, EditorProps, useEditorType } from "./types";
import { useTabStore } from "./use-tab-store";
import { EditorEvents, editorState, openInternalLink } from "./utils";
-
const publishNote = async () => {
const user = useUserStore.getState().user;
if (!user) {
@@ -469,12 +468,10 @@ export const useEditorEvents = (
case EventTypes.getAttachmentData: {
const attachment = (editorMessage.value as any)
- .attachment as Attachment;
+ ?.attachment as Attachment;
- console.log(
- "Getting attachment data:",
- attachment.hash,
- attachment.type
+ DatabaseLogger.log(
+ `Getting attachment data: ${attachment?.hash} ${attachment?.type}`
);
downloadAttachment(attachment.hash, true, {
base64: attachment.type === "image",
@@ -494,8 +491,8 @@ export const useEditorEvents = (
data
});
})
- .catch(() => {
- console.log("Error downloading attachment data");
+ .catch((e) => {
+ DatabaseLogger.error(e);
editor.postMessage(EditorEvents.attachmentData, {
resolverId: (editorMessage.value as any).resolverId,
data: undefined