Skip to content

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

mobile: load webclips in editor on demand

ammarahm-ed31d0164ba86a
diff --git a/apps/mobile/app/common/filesystem/io.js b/apps/mobile/app/common/filesystem/io.js
index 29bb58a59..6ab73847b 100644
--- a/apps/mobile/app/common/filesystem/io.js
+++ b/apps/mobile/app/common/filesystem/io.js
@@ -36,13 +36,12 @@ export async function readEncrypted(filename, key, cipherData) {
...cipherData,
hash: filename
},
- "base64"
+ cipherData.outputType === "base64" ? "base64" : "text"
);
return output;
} catch (e) {
RNFetchBlob.fs.unlink(path).catch(console.log);
console.log(e);
- console.log("error");
return false;
}
}
diff --git a/apps/mobile/app/screens/editor/index.tsx b/apps/mobile/app/screens/editor/index.tsx
index cad0adf85..eae8f4af6 100755
--- a/apps/mobile/app/screens/editor/index.tsx
+++ b/apps/mobile/app/screens/editor/index.tsx
@@ -98,17 +98,26 @@ const Editor = React.memo(
({
hash,
groupId,
- src
+ src,
+ attachmentType
}: {
hash: string;
groupId: string;
src: string;
+ attachmentType: string;
}) => {
if (groupId !== editor.note.current?.id) return;
- editor.commands.updateImage({
- hash: hash,
- src: src
- });
+ if (attachmentType === "webclip") {
+ editor.commands.updateWebclip({
+ hash: hash,
+ src: src
+ });
+ } else {
+ editor.commands.updateImage({
+ hash: hash,
+ src: src
+ });
+ }
},
[editor.commands, editor.note]
);
@@ -129,7 +138,7 @@ const Editor = React.memo(
useLayoutEffect(() => {
onLoad && onLoad();
- // eslint-disable-next-line react-hooks/exhaustive-deps
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [onLoad]);
if (withController) {
diff --git a/apps/mobile/app/screens/editor/tiptap/commands.ts b/apps/mobile/app/screens/editor/tiptap/commands.ts
index 7788c3a9f..974a35b1c 100644
--- a/apps/mobile/app/screens/editor/tiptap/commands.ts
+++ b/apps/mobile/app/screens/editor/tiptap/commands.ts
@@ -216,6 +216,14 @@ typeof globalThis.statusBar !== "undefined" && statusBar.current.set({date:"",sa
);
};
+ updateWebclip = async ({ src, hash }: ImageAttributes) => {
+ await this.doAsync(
+ `editor && editor.commands.updateWebclip(${JSON.stringify({
+ hash
+ })},${JSON.stringify({ src })})`
+ );
+ };
+
updateImage = async ({ src, hash }: ImageAttributes) => {
await this.doAsync(
`editor && editor.commands.updateImage(${JSON.stringify({
diff --git a/apps/mobile/app/screens/editor/tiptap/types.ts b/apps/mobile/app/screens/editor/tiptap/types.ts
index 638996e8c..4173482c4 100644
--- a/apps/mobile/app/screens/editor/tiptap/types.ts
+++ b/apps/mobile/app/screens/editor/tiptap/types.ts
@@ -82,6 +82,7 @@ export type Content = {
data?: string;
type: string;
noteId: string;
+ id?:string
};
export type SavePayload = {
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
index a1d912db5..f10ae4de7 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
@@ -346,13 +346,7 @@ export const useEditor = (
true
);
} else {
- const images = db.attachments?.ofNote(
- currentNote.current?.id,
- "images"
- );
- if (images && images.length > 0) {
- db.attachments?.downloadImages(currentNote.current.id);
- }
+ db.attachments?.downloadMedia(currentNote.current?.id);
}
}, 300);
};