Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
fix: clean up unused imports, add stagger delay for per-page chart loading
Cursor Agent7a6555da37f0
diff --git a/components/visitors/dataroom-view-stats.tsx b/components/visitors/dataroom-view-stats.tsxindex 75d13b1c..676a547b 100644--- a/components/visitors/dataroom-view-stats.tsx+++ b/components/visitors/dataroom-view-stats.tsx@@ -1,7 +1,5 @@import Link from "next/link";-import { useState } from "react";-import {DownloadCloudIcon,FileCheckIcon,diff --git a/components/visitors/dataroom-visitors-table.tsx b/components/visitors/dataroom-visitors-table.tsxindex 2e11a006..e7862004 100644--- a/components/visitors/dataroom-visitors-table.tsx+++ b/components/visitors/dataroom-visitors-table.tsx@@ -16,7 +16,7 @@ import {import { usePlan } from "@/lib/swr/use-billing";import { useDataroom } from "@/lib/swr/use-dataroom";import { useDataroomVisits } from "@/lib/swr/use-dataroom";-import { durationFormat, timeAgo } from "@/lib/utils";+import { timeAgo } from "@/lib/utils";import ChevronDown from "@/components/shared/icons/chevron-down";import { Button } from "@/components/ui/button";@@ -38,11 +38,10 @@ import { TimestampTooltip } from "@/components/ui/timestamp-tooltip";import { BadgeTooltip } from "@/components/ui/tooltip";import { ExportVisitsModal } from "../datarooms/export-visits-modal";+import { DataroomViewStats } from "./dataroom-view-stats";import DataroomVisitorCustomFields from "./dataroom-visitor-custom-fields";import { DataroomVisitorUserAgent } from "./dataroom-visitor-useragent";-import DataroomVisitHistory from "./dataroom-visitors-history";import { VisitorAvatar } from "./visitor-avatar";-import { DataroomViewStats } from "./dataroom-view-stats";export default function DataroomVisitorsTable({dataroomId,diff --git a/components/visitors/document-view-stats.tsx b/components/visitors/document-view-stats.tsxindex 87510f69..9acdb0b6 100644--- a/components/visitors/document-view-stats.tsx+++ b/components/visitors/document-view-stats.tsx@@ -1,16 +1,15 @@-import { useState } from "react";+import { useEffect, useRef, useState } from "react";import { ChevronRight, DownloadCloudIcon } from "lucide-react";import BarChartComponent from "@/components/charts/bar-chart";import StatsChartSkeleton from "@/components/documents/stats-chart-skeleton";+import { Gauge } from "@/components/ui/gauge";import { Skeleton } from "@/components/ui/skeleton";import { useDataroomDocumentPageStats } from "@/lib/swr/use-dataroom-view-document-stats";import { durationFormat } from "@/lib/utils";-import { Gauge } from "@/components/ui/gauge";-export function DocumentViewDuration({duration,loading,@@ -38,9 +37,7 @@ export function DocumentViewCompletion({if (loading) {return <Skeleton className="h-6 w-6 rounded-full" />;}- return (- <Gauge value={completionRate} size={"small"} showValue={true} />- );+ return <Gauge value={completionRate} size={"small"} showValue={true} />;}export function DocumentPageChart({@@ -67,13 +64,27 @@ export function DocumentPageChart({} | null;}) {const [isExpanded, setIsExpanded] = useState(false);+ const [fetchEnabled, setFetchEnabled] = useState(false);+ const timerRef = useRef<ReturnType<typeof setTimeout>>();++ useEffect(() => {+ if (isExpanded) {+ timerRef.current = setTimeout(() => {+ setFetchEnabled(true);+ }, 150);+ } else {+ clearTimeout(timerRef.current);+ setFetchEnabled(false);+ }+ return () => clearTimeout(timerRef.current);+ }, [isExpanded]);const { duration, loading } = useDataroomDocumentPageStats({dataroomId,dataroomViewId,documentViewId,documentId,- enabled: isExpanded,+ enabled: fetchEnabled,});const handleToggle = () => setIsExpanded((prev) => !prev);@@ -82,7 +93,7 @@ export function DocumentPageChart({return (<buttononClick={handleToggle}- className="flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"+ className="flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground"><ChevronRight className="h-3 w-3" />Show page-by-page@@ -95,7 +106,7 @@ export function DocumentPageChart({<div><buttononClick={handleToggle}- className="mb-1 flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"+ className="mb-1 flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground"><ChevronRight className="h-3 w-3 rotate-90 transition-transform" />Hide page-by-page@@ -111,8 +122,8 @@ export function DocumentPageChart({let downloadMessage = "";if (downloadType === "FOLDER" && downloadMetadata?.folderName) {downloadMessage = `Downloaded without viewing via folder "${downloadMetadata.folderName}"`;- } else if (downloadType === "BULK" && downloadMetadata?.dataroomName) {- downloadMessage = `Downloaded without viewing via bulk download`;+ } else if (downloadType === "BULK") {+ downloadMessage = "Downloaded without viewing via bulk download";} else if (downloadType === "SINGLE") {downloadMessage = "Downloaded without viewing";} else {@@ -123,7 +134,7 @@ export function DocumentPageChart({<div><buttononClick={handleToggle}- className="mb-1 flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"+ className="mb-1 flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground"><ChevronRight className="h-3 w-3 rotate-90 transition-transform" />Hide page-by-page@@ -142,9 +153,7 @@ export function DocumentPageChart({}));durationData = durationData.map((item) => {- const match = duration.data.find(- (d) => d.pageNumber === item.pageNumber,- );+ const match = duration.data.find((d) => d.pageNumber === item.pageNumber);return match || item;});@@ -152,7 +161,7 @@ export function DocumentPageChart({<div><buttononClick={handleToggle}- className="mb-1 flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"+ className="mb-1 flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground"><ChevronRight className="h-3 w-3 rotate-90 transition-transform" />Hide page-by-page