feat: refactor DesktopWorkspace to use new contexts for asset and tag interactions
This commit is contained in:
@@ -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<unknown>;
|
||||
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<DesktopWorkspaceProps> = ({
|
||||
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<DesktopWorkspaceProps> = ({
|
||||
// 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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user