cleanup
This commit is contained in:
@@ -27,7 +27,7 @@ interface DocumentsPanelProps {
|
||||
|
||||
const defaultGetDocumentAsset = (_doc?: unknown, _type?: string) => null;
|
||||
|
||||
export type PreviewEntryLike = { url?: string | null; contentType?: string | null };
|
||||
export type DocumentLinkLike = { url?: string | null; contentType?: string | null };
|
||||
|
||||
const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
headerConfig,
|
||||
@@ -62,7 +62,7 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
onDocumentTagDrop,
|
||||
viewMode = 'list',
|
||||
onViewModeChange: _onViewModeChange,
|
||||
previewEntries,
|
||||
documentLinks,
|
||||
ensureDownloadUrl,
|
||||
deskWorkspaceProps = null,
|
||||
}): ReactNode => {
|
||||
@@ -75,7 +75,7 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
} = useWorkspaceSelectionContext();
|
||||
const showingSearchResults = searchResults !== null;
|
||||
const rows = showingSearchResults ? searchResults : documents;
|
||||
const previewEntryMap = previewEntries instanceof Map ? previewEntries : null;
|
||||
const documentLinkMap = documentLinks instanceof Map ? documentLinks : null;
|
||||
|
||||
const currentFolderId = useMemo(() => {
|
||||
if (showingSearchResults) {
|
||||
@@ -159,7 +159,7 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
const zoomDisplay = previewZoomSource;
|
||||
const overlayDocument = useMemo(() => (
|
||||
previewDoc && zoomDisplay?.url
|
||||
? { ...previewDoc, previewEntry: zoomDisplay }
|
||||
? { ...previewDoc, documentLink: zoomDisplay }
|
||||
: previewDoc
|
||||
), [previewDoc, zoomDisplay]);
|
||||
|
||||
@@ -175,7 +175,7 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
const versionContentType = previewDoc.current_version?.version?.content_type;
|
||||
const contentFallback = docContentType || versionContentType || null;
|
||||
|
||||
const applyEntry = (entry?: PreviewEntryLike | null) => {
|
||||
const applyEntry = (entry?: DocumentLinkLike | null) => {
|
||||
if (!entry?.url) {
|
||||
setPreviewZoomSource(null);
|
||||
return;
|
||||
@@ -187,7 +187,7 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
});
|
||||
};
|
||||
|
||||
const cachedEntry = previewEntryMap?.get(previewDocId) || null;
|
||||
const cachedEntry = documentLinkMap?.get(previewDocId) || null;
|
||||
if (cachedEntry?.url) {
|
||||
applyEntry(cachedEntry);
|
||||
return () => {
|
||||
@@ -218,7 +218,7 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [previewDocId, previewDoc, previewEntryMap, ensureDownloadUrl]);
|
||||
}, [previewDocId, previewDoc, documentLinkMap, ensureDownloadUrl]);
|
||||
|
||||
const closePreviewOverlay = useCallback(() => {
|
||||
setPreviewDocId(null);
|
||||
@@ -230,12 +230,12 @@ const DocumentsPanel: React.FC<DocumentsPanelProps> = ({
|
||||
if (!doc || !doc.id) {
|
||||
return;
|
||||
}
|
||||
if (!ensureDownloadUrl && !(previewEntryMap?.get(doc.id)?.url)) {
|
||||
if (!ensureDownloadUrl && !(documentLinkMap?.get(doc.id)?.url)) {
|
||||
return;
|
||||
}
|
||||
setPreviewDocId(doc.id);
|
||||
},
|
||||
[ensureDownloadUrl, previewEntryMap],
|
||||
[ensureDownloadUrl, documentLinkMap],
|
||||
);
|
||||
|
||||
const handleDocumentActivate = useCallback(
|
||||
|
||||
Reference in New Issue
Block a user