cleanup
This commit is contained in:
@@ -32,14 +32,14 @@ import '../styles/workspace/workspace-cards.css';
|
||||
type Identifier = string | number;
|
||||
|
||||
type TagLike = { id?: Identifier | null; label?: string; color?: string | null } | null;
|
||||
type PreviewEntryLike = { url?: string | null; contentType?: string | null };
|
||||
type DocumentLinkLike = { url?: string | null; contentType?: string | null };
|
||||
type OverlaySource = { url: string; alt?: string | null; contentType?: string | null };
|
||||
|
||||
export interface DeskDocument {
|
||||
id?: Identifier | null;
|
||||
title?: string;
|
||||
tags?: TagLike[] | null;
|
||||
previewEntry?: OverlaySource | null;
|
||||
documentLink?: OverlaySource | null;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
||||
onClearSelection = null,
|
||||
tenantId = null,
|
||||
viewId = 'default',
|
||||
previewEntries,
|
||||
documentLinks,
|
||||
ensureDownloadUrl,
|
||||
}) => {
|
||||
const items = useMemo<DeskDocument[]>(
|
||||
@@ -217,7 +217,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
||||
);
|
||||
|
||||
const allowLayoutPersistence = Boolean(tenantId && viewId && viewId.startsWith('folder:'));
|
||||
const previewEntryMap = previewEntries instanceof Map ? previewEntries : null;
|
||||
const documentLinkMap = documentLinks instanceof Map ? documentLinks : null;
|
||||
|
||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||
const itemRefs = useRef<Map<string, HTMLDivElement | null>>(new Map());
|
||||
@@ -562,7 +562,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
||||
const docContentType = doc?.content_type ?? null;
|
||||
const versionContentType = (doc?.current_version as { version?: { content_type?: string | null } } | null)?.version?.content_type ?? null;
|
||||
|
||||
const applyEntry = (entry?: PreviewEntryLike | null) => {
|
||||
const applyEntry = (entry?: DocumentLinkLike | null) => {
|
||||
if (!entry?.url) {
|
||||
setOverlaySource(null);
|
||||
return;
|
||||
@@ -574,7 +574,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
||||
});
|
||||
};
|
||||
|
||||
const cachedEntry = previewEntryMap?.get(docIdentifier) || null;
|
||||
const cachedEntry = documentLinkMap?.get(docIdentifier) || null;
|
||||
if (cachedEntry?.url) {
|
||||
applyEntry(cachedEntry);
|
||||
return () => {
|
||||
@@ -605,7 +605,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [overlayDocId, documentLookup, previewEntryMap, ensureDownloadUrl]);
|
||||
}, [overlayDocId, documentLookup, documentLinkMap, ensureDownloadUrl]);
|
||||
|
||||
const closeOverlay = useCallback(() => {
|
||||
setOverlayDocId(null);
|
||||
@@ -666,7 +666,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
||||
}
|
||||
const baseDoc = documentLookup.get(String(overlayDocId)) || null;
|
||||
if (baseDoc && overlayDisplay?.url) {
|
||||
return { ...baseDoc, previewEntry: overlayDisplay };
|
||||
return { ...baseDoc, documentLink: overlayDisplay };
|
||||
}
|
||||
return baseDoc;
|
||||
}, [documentLookup, overlayDisplay, overlayDocId]);
|
||||
|
||||
Reference in New Issue
Block a user