cleanup
This commit is contained in:
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
|
||||
|
||||
type Identifier = string | number;
|
||||
|
||||
interface PreviewEntryLike {
|
||||
interface DocumentLinkLike {
|
||||
url?: string | null;
|
||||
contentType?: string | null;
|
||||
}
|
||||
@@ -70,8 +70,8 @@ export interface UseDocumentsPanelPropsArgs {
|
||||
handleBulkSelectionReanalyze?: (...args: unknown[]) => void;
|
||||
folderOptions?: unknown[];
|
||||
moveDocumentsToFolder?: (...args: unknown[]) => void;
|
||||
previewEntries?: Map<Identifier, PreviewEntryLike>;
|
||||
ensureDownloadUrl?: (documentId: Identifier, options?: { force?: boolean }) => Promise<PreviewEntryLike | null>;
|
||||
documentLinks?: Map<Identifier, DocumentLinkLike>;
|
||||
ensureDownloadUrl?: (documentId: Identifier, options?: { force?: boolean }) => Promise<DocumentLinkLike | null>;
|
||||
}
|
||||
|
||||
export type DocumentsPanelProps = ReturnType<typeof useDocumentsPanelProps>;
|
||||
@@ -126,7 +126,7 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
||||
handleBulkSelectionReanalyze,
|
||||
folderOptions,
|
||||
moveDocumentsToFolder,
|
||||
previewEntries,
|
||||
documentLinks,
|
||||
ensureDownloadUrl,
|
||||
} = props;
|
||||
|
||||
@@ -182,7 +182,7 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
||||
onBulkReanalyze: handleBulkSelectionReanalyze,
|
||||
folderOptions,
|
||||
onMoveDocumentsToFolder: moveDocumentsToFolder,
|
||||
previewEntries,
|
||||
documentLinks,
|
||||
ensureDownloadUrl,
|
||||
}),
|
||||
[
|
||||
@@ -234,7 +234,7 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
||||
ensureAssetUrl,
|
||||
getDocumentAsset,
|
||||
folderOptions,
|
||||
previewEntries,
|
||||
documentLinks,
|
||||
ensureDownloadUrl,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -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