From 5632d2252a805564739f34f545d760f3b656d97a Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Mon, 8 Dec 2025 12:40:25 +0100 Subject: [PATCH] feat: refactor `DesktopWorkspace` to use new contexts for asset and tag interactions --- .../desktop/components/DesktopWorkspace.tsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/src/desktop/components/DesktopWorkspace.tsx b/frontend/src/desktop/components/DesktopWorkspace.tsx index 6b1604e..b369c7e 100644 --- a/frontend/src/desktop/components/DesktopWorkspace.tsx +++ b/frontend/src/desktop/components/DesktopWorkspace.tsx @@ -19,6 +19,8 @@ import type { Identifier } from '../../types/identifiers'; import type { DocumentsListEntry, Document } from '../../types/documents'; import { useAppState } from '../../lib/store/appState'; import { useDocumentOpen } from '../../lib/context/DocumentOpenContext'; +import { useDocumentsAssetContext } from '../../documents/context/DocumentsAssetContext'; +import { useDocumentsCommandContext } from '../../documents/context/DocumentsCommandContext'; interface DocumentSizeInfo { width: number; @@ -34,26 +36,24 @@ const computeFallbackCardSize = (_doc: Document, defaultSize: number = 200): Doc interface DesktopWorkspaceProps { entries: DocumentsListEntry[]; - ensureAssetUrl?: (...args: any[]) => Promise; - getDocumentAsset?: (...args: any[]) => unknown; onSelectionChange?: (selectedIds: Identifier[]) => void; - onDocumentTagAttach?: (docId: Identifier, tagId: Identifier) => void; - onDocumentTagDetach?: (docId: Identifier, tagId: Identifier) => void; viewId?: string | null; defaultCardSize?: number; } const DesktopWorkspaceContent: React.FC = ({ entries, - ensureAssetUrl, - getDocumentAsset, onSelectionChange, - onDocumentTagAttach, - onDocumentTagDetach, viewId, defaultCardSize = 200, }) => { const { openDocument } = useDocumentOpen(); + const { + ensureAssetUrl, + getDocumentAsset + } = useDocumentsAssetContext(); + const { tags } = useDocumentsCommandContext(); + const { tenant } = useAppState(); const tenantId = tenant?.id as Identifier; const { addPointer, removePointer } = usePointerTracking(); @@ -182,10 +182,10 @@ const DesktopWorkspaceContent: React.FC = ({ // Tag Interactions const tagInteractions = useDeskTagInteractions({ onAssignTagToDocument: (docId: string, tagId: string) => { - onDocumentTagAttach?.(docId, tagId); + tags.onAttach?.(docId, tagId); }, onRemoveTagFromDocument: (docId: string, tagId: string) => { - onDocumentTagDetach?.(docId, tagId); + tags.onDetach?.(docId, tagId); }, requestCanvasFocus: focusShell, });