Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
fix: fixed the document delete issue
ashrafchowdury0aa170642b76
diff --git a/components/documents/document-card.tsx b/components/documents/document-card.tsxindex 32252ec3..9f60a22d 100644--- a/components/documents/document-card.tsx+++ b/components/documents/document-card.tsx@@ -18,6 +18,7 @@ import {DropdownMenuTrigger,} from "../ui/dropdown-menu";import { TrashIcon, Link as LinkIcon, MoreVertical } from "lucide-react";+import { useSWRConfig } from "swr";type DocumentsCardProps = {document: DocumentWithLinksAndLinkCountAndViewCount;@@ -27,6 +28,7 @@ export default function DocumentsCard({document,teamInfo,}: DocumentsCardProps) {+ const { mutate } = useSWRConfig();const router = useRouter();function handleCopyToClipboard(id: string) {@@ -71,6 +73,16 @@ export default function DocumentsCard({);if (response.ok) {+ // remove the document from the cache+ mutate(`/api/teams/${teamInfo?.currentTeam?.id}/documents`, null, {+ populateCache: (_, docs) => {+ return docs.filter(+ (doc: DocumentWithLinksAndLinkCountAndViewCount) =>+ doc.id !== documentId,+ );+ },+ revalidate: false,+ });toast.success("Document deleted successfully.");} else {const { message } = await response.json();