Skip to content

Commit

Permalink
web: use bloburl when previewing images
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodrr committed Nov 20, 2023
1 parent 6826090 commit a101dbd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/web/src/components/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,15 @@ export function Editor(props: EditorProps) {
onContentChange={onContentChange}
onChange={onEditorChange}
onDownloadAttachment={(attachment) => saveAttachment(attachment.hash)}
onPreviewAttachment={async ({ hash, dataurl }) => {
onPreviewAttachment={async (data) => {
const { hash } = data;
const attachment = db.attachments?.attachment(hash);
if (attachment && attachment.metadata.type.startsWith("image/")) {
const container = document.getElementById("dialogContainer");
if (!(container instanceof HTMLElement)) return;

dataurl = dataurl || (await downloadAttachment(hash, "base64"));
const dataurl =
data.bloburl || (await downloadAttachment(hash, "base64"));
if (!dataurl)
return showToast("error", "This image cannot be previewed.");

Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/editor/picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export type Attachment = {
mime: string;
size: number;
dataurl?: string;
bloburl?: string;
};

type AddAttachmentOptions = {
Expand Down

0 comments on commit a101dbd

Please sign in to comment.