From 66a0be42bd5488ff5ee2f62c9732b6fa71d5b7d4 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Fri, 5 Dec 2025 00:41:00 +0100 Subject: [PATCH] cleanup --- .../documents/data/useDocumentsWorkspace.ts | 55 +++++-- .../documents/data/useWorkspaceTaxonomies.ts | 134 ------------------ 2 files changed, 46 insertions(+), 143 deletions(-) delete mode 100644 frontend/src/documents/data/useWorkspaceTaxonomies.ts diff --git a/frontend/src/documents/data/useDocumentsWorkspace.ts b/frontend/src/documents/data/useDocumentsWorkspace.ts index 4b8b407..3416adf 100644 --- a/frontend/src/documents/data/useDocumentsWorkspace.ts +++ b/frontend/src/documents/data/useDocumentsWorkspace.ts @@ -48,7 +48,10 @@ import useDocumentUploads from '../features/upload/useDocumentUploads'; import useDocumentDragHandlers from '../features/upload/useDocumentDragHandlers'; import useDocumentMutations from './useDocumentMutations'; import useDetailWorkspace from '../../viewer/logic/useDetailWorkspace'; -import useWorkspaceTaxonomies from './useWorkspaceTaxonomies'; +import useTags from './useTags'; +import useCorrespondents from './useCorrespondents'; +import useDocumentCorrespondentActions from '../features/correspondents/useDocumentCorrespondentActions'; +import usePasskeys from '../../settings/usePasskeys'; import useWorkspaceBreadcrumbs from '../logic/useWorkspaceBreadcrumbs'; import useWorkspaceSelectionSync from '../features/selection/useWorkspaceSelectionSync'; import type { DocumentId, FolderNodeId, Identifier } from '../../types/identifiers'; @@ -484,17 +487,57 @@ const useDocumentsWorkspace = ({ handleTagUpdate, handleTagDelete, setTags, - tagLookupById, + } = useTags({ + notifyApiError, + setStatusMessage, + tagManager, + tenantIdRef, + setActiveTagFilters, + mapDocumentCaches, + }); + + useEffect(() => { + tenantIdRef.current = currentTenantId; + }, [currentTenantId, tenantIdRef]); + + const tagLookupById = useMemo(() => { + const map = new Map(); + tags.forEach((tag) => { + if (tag?.id) { + map.set(tag.id, tag); + } + }); + return map; + }, [tags]); + + const { correspondents, refreshCorrespondents, handleCorrespondentCreate, handleCorrespondentUpdate, handleCorrespondentDelete, setCorrespondents, + } = useCorrespondents({ + notifyApiError, + setStatusMessage, + tenantIdRef, + mapDocumentCaches, + }); + + const { correspondentLookupByName, handleDocumentCorrespondentAttach, handleCorrespondentRemove, handleCorrespondentAdd, + } = useDocumentCorrespondentActions({ + correspondents, + handleCorrespondentCreate, + notifyApiError, + setStatusMessage, + updateDocumentCaches, + }); + + const { passkeys, passkeysSupported, passkeysLoading, @@ -503,15 +546,9 @@ const useDocumentsWorkspace = ({ refreshPasskeys, registerPasskey, revokePasskey, - } = useWorkspaceTaxonomies({ + } = usePasskeys({ notifyApiError, setStatusMessage, - tagManager, - tenantIdRef, - currentTenantId, - setActiveTagFilters, - mapDocumentCaches, - updateDocumentCaches, token, }); diff --git a/frontend/src/documents/data/useWorkspaceTaxonomies.ts b/frontend/src/documents/data/useWorkspaceTaxonomies.ts deleted file mode 100644 index 6d7d3c0..0000000 --- a/frontend/src/documents/data/useWorkspaceTaxonomies.ts +++ /dev/null @@ -1,134 +0,0 @@ -import { useEffect, useMemo } from 'react'; -import type { Dispatch, MutableRefObject, SetStateAction } from 'react'; -import usePasskeys from '../../settings/usePasskeys'; -import TagManager from '../../lib/assets/TagManager'; -import useCorrespondents from './useCorrespondents'; -import useDocumentCorrespondentActions from '../features/correspondents/useDocumentCorrespondentActions'; -import useTags from './useTags'; -import type { Identifier } from '../../types/identifiers'; - -interface UseWorkspaceTaxonomiesArgs { - notifyApiError: (error: unknown, fallbackMessage?: string, variant?: string) => void; - setStatusMessage: (message: string, variant?: string) => void; - tagManager: TagManager; - tenantIdRef: MutableRefObject; - currentTenantId: Identifier | null; - setActiveTagFilters: Dispatch>; - mapDocumentCaches: (mapper: (doc: any) => any | undefined) => void; - updateDocumentCaches: (id: Identifier, updater: (doc: any) => any) => void; - token: string; -} - -const useWorkspaceTaxonomies = ({ - notifyApiError, - setStatusMessage, - tagManager, - tenantIdRef, - currentTenantId, - setActiveTagFilters, - mapDocumentCaches, - updateDocumentCaches, - token, -}: UseWorkspaceTaxonomiesArgs) => { - const { - tags, - refreshTags, - handleTagCreate, - handleTagUpdate, - handleTagDelete, - setTags, - } = useTags({ - notifyApiError, - setStatusMessage, - tagManager, - tenantIdRef, - setActiveTagFilters, - mapDocumentCaches, - }); - - useEffect(() => { - tenantIdRef.current = currentTenantId; - }, [currentTenantId, tenantIdRef]); - - const tagLookupById = useMemo(() => { - const map = new Map(); - tags.forEach((tag) => { - if (tag?.id) { - map.set(tag.id, tag); - } - }); - return map; - }, [tags]); - - const { - correspondents, - refreshCorrespondents, - handleCorrespondentCreate, - handleCorrespondentUpdate, - handleCorrespondentDelete, - setCorrespondents, - } = useCorrespondents({ - notifyApiError, - setStatusMessage, - tenantIdRef, - mapDocumentCaches, - }); - - const { - correspondentLookupByName, - handleDocumentCorrespondentAttach, - handleCorrespondentRemove, - handleCorrespondentAdd, - } = useDocumentCorrespondentActions({ - correspondents, - handleCorrespondentCreate, - notifyApiError, - setStatusMessage, - updateDocumentCaches, - }); - - const { - passkeys, - passkeysSupported, - passkeysLoading, - registeringPasskey, - revokingPasskeyId, - refreshPasskeys, - registerPasskey, - revokePasskey, - } = usePasskeys({ - notifyApiError, - setStatusMessage, - token, - }); - - return { - tags, - refreshTags, - handleTagCreate, - handleTagUpdate, - handleTagDelete, - setTags, - tagLookupById, - correspondents, - refreshCorrespondents, - handleCorrespondentCreate, - handleCorrespondentUpdate, - handleCorrespondentDelete, - setCorrespondents, - correspondentLookupByName, - handleDocumentCorrespondentAttach, - handleCorrespondentRemove, - handleCorrespondentAdd, - passkeys, - passkeysSupported, - passkeysLoading, - registeringPasskey, - revokingPasskeyId, - refreshPasskeys, - registerPasskey, - revokePasskey, - }; -}; - -export default useWorkspaceTaxonomies;