Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: add try catch to avoid blocking popups
Marc Seitzcf5ff41f53ab
diff --git a/components/datarooms/export-visits-modal.tsx b/components/datarooms/export-visits-modal.tsxindex 1e9e8b3e..bd6c465a 100644--- a/components/datarooms/export-visits-modal.tsx+++ b/components/datarooms/export-visits-modal.tsx@@ -120,18 +120,24 @@ export function ExportVisitsModal({// Create a direct link to the API endpoint (it will redirect to blob)const downloadUrl = `/api/teams/${teamId}/export-jobs/${data.exportId}?download=true`;- const link = window.document.createElement("a");- link.href = downloadUrl;- link.setAttribute(- "download",- `${statusData.resourceName || dataroomName}_${groupName ? `${groupName}_` : ""}visits_${new Date().toISOString().split("T")[0]}.csv`,- );- link.rel = "noopener noreferrer";- link.style.display = "none";-- window.document.body.appendChild(link);- link.click();- window.document.body.removeChild(link);+ try {+ const link = window.document.createElement("a");+ link.href = downloadUrl;+ link.setAttribute(+ "download",+ `${statusData.resourceName || dataroomName}_${groupName ? `${groupName}_` : ""}visits_${new Date().toISOString().split("T")[0]}.csv`,+ );+ link.rel = "noopener noreferrer";+ link.style.display = "none";++ window.document.body.appendChild(link);+ link.click();+ window.document.body.removeChild(link);+ } catch (error) {+ // Fallback: open in new tab if programmatic download fails+ window.open(downloadUrl, "_blank");+ console.error("Download failed, opened in new tab:", error);+ }handleClose();toast.success("Export successfully downloaded");@@ -149,7 +155,7 @@ export function ExportVisitsModal({} catch (error) {console.error("Error polling export status:", error);}- }, 3000); // Poll every 3 seconds+ }, 5000); // Poll every 5 seconds// Clear interval after 10 minutes to prevent indefinite pollingsetTimeout(() => {diff --git a/components/documents/export-visits-modal.tsx b/components/documents/export-visits-modal.tsxindex 19710451..2900fd2a 100644--- a/components/documents/export-visits-modal.tsx+++ b/components/documents/export-visits-modal.tsx@@ -115,18 +115,24 @@ export function ExportVisitsModal({// Create a direct link to the API endpoint (it will redirect to blob)const downloadUrl = `/api/teams/${teamId}/export-jobs/${data.exportId}?download=true`;- const link = window.document.createElement("a");- link.href = downloadUrl;- link.setAttribute(- "download",- `${statusData.resourceName || document.name}_visits_${new Date().toISOString().split("T")[0]}.csv`,- );- link.rel = "noopener noreferrer";- link.style.display = "none";+ try {+ const link = window.document.createElement("a");+ link.href = downloadUrl;+ link.setAttribute(+ "download",+ `${statusData.resourceName || document.name}_visits_${new Date().toISOString().split("T")[0]}.csv`,+ );+ link.rel = "noopener noreferrer";+ link.style.display = "none";- window.document.body.appendChild(link);- link.click();- window.document.body.removeChild(link);+ window.document.body.appendChild(link);+ link.click();+ window.document.body.removeChild(link);+ } catch (error) {+ // Fallback: open in new tab if programmatic download fails+ window.open(downloadUrl, "_blank");+ console.error("Download failed, opened in new tab:", error);+ }handleClose();toast.success("Export successfully downloaded");@@ -144,7 +150,7 @@ export function ExportVisitsModal({} catch (error) {console.error("Error polling export status:", error);}- }, 3000); // Poll every 3 seconds+ }, 5000); // Poll every 5 seconds// Clear interval after 10 minutes to prevent indefinite pollingsetTimeout(() => {