⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
Merge branch 'main' into fix/issue-1633
Danielfc1a8478ff87
diff --cc apps/web/components/PreserverdFormatRow.tsxindex 88c9e570,56525b17..58d87ad7--- a/apps/web/components/PreserverdFormatRow.tsx+++ b/apps/web/components/PreserverdFormatRow.tsx@@@ -22,30 -24,51 +24,51 @@@ export default function PreservedFormatdownloadable,}: Props) {const router = useRouter();+ const { data: config, isLoading: isConfigLoading } = useConfig();- const isPublic = router.pathname.startsWith("/public") ? true : undefined;+ const isPublic = router.pathname.startsWith("/public");+ const isMonolithConfigPending =+ format === ArchivedFormat.monolith && isConfigLoading && !config;- const handleDownload = () => {- const path = `/api/v1/archives/${link?.id}?format=${format}`;- fetch(path)- .then((response) => {- if (response.ok) {- const anchorElement = document.createElement("a");- anchorElement.href = path;- anchorElement.download =- format === ArchivedFormat.monolith- ? "Webpage"- : format === ArchivedFormat.pdf- ? "PDF"- : "Screenshot";- anchorElement.click();- } else {- console.error("Failed to download file");+ const handleDownload = async () => {+ if (typeof link.id !== "number" || isMonolithConfigPending) {+ return;+ }++ try {+ const isCrossOriginMonolith =+ format === ArchivedFormat.monolith && config?.USER_CONTENT_DOMAIN;+ const path = isCrossOriginMonolith+ ? await getPreservedFormatUrl({+ tokenEndpoint: "/api/v1/preserved/token",+ linkId: link.id,+ format,+ download: true,+ requestInit: {+ cache: "no-store",+ },+ })+ : `/api/v1/archives/${link?.id}?format=${format}`;++ if (!isCrossOriginMonolith) {+ const response = await fetch(path);+ if (!response.ok) {+ throw new Error("Failed to download file");}- })- .catch((error) => {- console.error("Error:", error);- });+ }++ const anchorElement = document.createElement("a");+ anchorElement.href = path;+ anchorElement.download =+ format === ArchivedFormat.monolith+ ? "Webpage"+ : format === ArchivedFormat.pdf+ ? "PDF"+ : "Screenshot";+ anchorElement.click();+ } catch (error) {+ console.error("Error:", error);+ }};return (