feat: Refactor tag and correspondent management to use canonical types and dedicated managers.
This commit is contained in:
@@ -6,6 +6,8 @@ import { LayoutCard } from '../logic/LayoutSystem';
|
||||
import { useCardPointer } from '../interactions/useCardPointer';
|
||||
import DocumentTags from '../../documents/components/DocumentTags';
|
||||
import { TagInteractionHandlers } from '../../documents/interactions/useTagInteractions';
|
||||
import { useDocumentsAssetContext } from '../../documents/context/DocumentsAssetContext';
|
||||
import { useDocumentsViewStateContext } from '../../documents/context/DocumentsViewStateContext';
|
||||
|
||||
const preventAll = (event?: React.SyntheticEvent | Event | null) => {
|
||||
if (!event) return;
|
||||
@@ -38,8 +40,6 @@ const DesktopDocumentCard: React.FC<DesktopDocumentCardProps> = ({
|
||||
matchesFilter = true,
|
||||
selected = false,
|
||||
docTagTokens,
|
||||
ensureAssetUrl,
|
||||
getDocumentAsset,
|
||||
onDocumentActivate,
|
||||
onSelect,
|
||||
onDeselect,
|
||||
@@ -48,6 +48,12 @@ const DesktopDocumentCard: React.FC<DesktopDocumentCardProps> = ({
|
||||
tagHandlers,
|
||||
layoutCard,
|
||||
}) => {
|
||||
const {
|
||||
ensureAssetUrl,
|
||||
getDocumentAsset
|
||||
} = useDocumentsAssetContext();
|
||||
|
||||
const { tagLookupById, correspondentLookupById } = useDocumentsViewStateContext();
|
||||
const cardPointerHandlers = useCardPointer(
|
||||
layoutCard,
|
||||
!!selected,
|
||||
@@ -58,7 +64,7 @@ const DesktopDocumentCard: React.FC<DesktopDocumentCardProps> = ({
|
||||
requestCanvasFocus
|
||||
);
|
||||
|
||||
const correspondents = useMemo(() => resolveCorrespondents(doc), [doc]);
|
||||
const correspondents = useMemo(() => resolveCorrespondents(doc, correspondentLookupById), [doc, correspondentLookupById]);
|
||||
const tags = Array.isArray(doc?.tags) ? doc.tags : [];
|
||||
|
||||
const itemClasses = ['desk-item'];
|
||||
@@ -116,6 +122,7 @@ const DesktopDocumentCard: React.FC<DesktopDocumentCardProps> = ({
|
||||
<DocumentTags
|
||||
doc={doc}
|
||||
tags={tags}
|
||||
tagLookupById={tagLookupById}
|
||||
tagHandlers={tagHandlers}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user