feat: refactor DesktopWorkspace to use new contexts for asset and tag interactions

This commit is contained in:
2025-12-08 12:40:25 +01:00
parent 73468bbb02
commit 5632d2252a
@@ -19,6 +19,8 @@ import type { Identifier } from '../../types/identifiers';
import type { DocumentsListEntry, Document } from '../../types/documents'; import type { DocumentsListEntry, Document } from '../../types/documents';
import { useAppState } from '../../lib/store/appState'; import { useAppState } from '../../lib/store/appState';
import { useDocumentOpen } from '../../lib/context/DocumentOpenContext'; import { useDocumentOpen } from '../../lib/context/DocumentOpenContext';
import { useDocumentsAssetContext } from '../../documents/context/DocumentsAssetContext';
import { useDocumentsCommandContext } from '../../documents/context/DocumentsCommandContext';
interface DocumentSizeInfo { interface DocumentSizeInfo {
width: number; width: number;
@@ -34,26 +36,24 @@ const computeFallbackCardSize = (_doc: Document, defaultSize: number = 200): Doc
interface DesktopWorkspaceProps { interface DesktopWorkspaceProps {
entries: DocumentsListEntry[]; entries: DocumentsListEntry[];
ensureAssetUrl?: (...args: any[]) => Promise<unknown>;
getDocumentAsset?: (...args: any[]) => unknown;
onSelectionChange?: (selectedIds: Identifier[]) => void; onSelectionChange?: (selectedIds: Identifier[]) => void;
onDocumentTagAttach?: (docId: Identifier, tagId: Identifier) => void;
onDocumentTagDetach?: (docId: Identifier, tagId: Identifier) => void;
viewId?: string | null; viewId?: string | null;
defaultCardSize?: number; defaultCardSize?: number;
} }
const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
entries, entries,
ensureAssetUrl,
getDocumentAsset,
onSelectionChange, onSelectionChange,
onDocumentTagAttach,
onDocumentTagDetach,
viewId, viewId,
defaultCardSize = 200, defaultCardSize = 200,
}) => { }) => {
const { openDocument } = useDocumentOpen(); const { openDocument } = useDocumentOpen();
const {
ensureAssetUrl,
getDocumentAsset
} = useDocumentsAssetContext();
const { tags } = useDocumentsCommandContext();
const { tenant } = useAppState(); const { tenant } = useAppState();
const tenantId = tenant?.id as Identifier; const tenantId = tenant?.id as Identifier;
const { addPointer, removePointer } = usePointerTracking(); const { addPointer, removePointer } = usePointerTracking();
@@ -182,10 +182,10 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
// Tag Interactions // Tag Interactions
const tagInteractions = useDeskTagInteractions({ const tagInteractions = useDeskTagInteractions({
onAssignTagToDocument: (docId: string, tagId: string) => { onAssignTagToDocument: (docId: string, tagId: string) => {
onDocumentTagAttach?.(docId, tagId); tags.onAttach?.(docId, tagId);
}, },
onRemoveTagFromDocument: (docId: string, tagId: string) => { onRemoveTagFromDocument: (docId: string, tagId: string) => {
onDocumentTagDetach?.(docId, tagId); tags.onDetach?.(docId, tagId);
}, },
requestCanvasFocus: focusShell, requestCanvasFocus: focusShell,
}); });