Use backend endpoint for attachment downloads
This commit is contained in:
@@ -9,10 +9,9 @@ import {
|
||||
} from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { ChevronLeft, ChevronRight, Download, X } from "lucide-react";
|
||||
import { postNoBody } from "../../../api";
|
||||
import type { Attachment } from "../../../types/post";
|
||||
import { autolink } from "../utils/autolink";
|
||||
import { downloadFile } from "../utils/downloadFile";
|
||||
import { downloadAttachment, downloadFile } from "../utils/downloadFile";
|
||||
|
||||
type LightboxState = {
|
||||
images: Attachment[];
|
||||
@@ -143,11 +142,12 @@ function LightboxView({
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
if (postId) {
|
||||
void postNoBody(
|
||||
`/api/posts/${postId}/attachments/${current.id}/download`,
|
||||
void downloadAttachment(postId, current.id, current.filename).catch(
|
||||
() => {},
|
||||
);
|
||||
} else {
|
||||
void downloadFile(current.url, current.filename).catch(() => {});
|
||||
}
|
||||
void downloadFile(current.url, current.filename).catch(() => {});
|
||||
}}
|
||||
className="absolute right-16 top-4 z-10 flex h-10 w-10 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20"
|
||||
aria-label="Download"
|
||||
|
||||
Reference in New Issue
Block a user