cleanup
This commit is contained in:
@@ -48,7 +48,10 @@ import useDocumentUploads from '../features/upload/useDocumentUploads';
|
|||||||
import useDocumentDragHandlers from '../features/upload/useDocumentDragHandlers';
|
import useDocumentDragHandlers from '../features/upload/useDocumentDragHandlers';
|
||||||
import useDocumentMutations from './useDocumentMutations';
|
import useDocumentMutations from './useDocumentMutations';
|
||||||
import useDetailWorkspace from '../../viewer/logic/useDetailWorkspace';
|
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 useWorkspaceBreadcrumbs from '../logic/useWorkspaceBreadcrumbs';
|
||||||
import useWorkspaceSelectionSync from '../features/selection/useWorkspaceSelectionSync';
|
import useWorkspaceSelectionSync from '../features/selection/useWorkspaceSelectionSync';
|
||||||
import type { DocumentId, FolderNodeId, Identifier } from '../../types/identifiers';
|
import type { DocumentId, FolderNodeId, Identifier } from '../../types/identifiers';
|
||||||
@@ -484,17 +487,57 @@ const useDocumentsWorkspace = ({
|
|||||||
handleTagUpdate,
|
handleTagUpdate,
|
||||||
handleTagDelete,
|
handleTagDelete,
|
||||||
setTags,
|
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,
|
correspondents,
|
||||||
refreshCorrespondents,
|
refreshCorrespondents,
|
||||||
handleCorrespondentCreate,
|
handleCorrespondentCreate,
|
||||||
handleCorrespondentUpdate,
|
handleCorrespondentUpdate,
|
||||||
handleCorrespondentDelete,
|
handleCorrespondentDelete,
|
||||||
setCorrespondents,
|
setCorrespondents,
|
||||||
|
} = useCorrespondents({
|
||||||
|
notifyApiError,
|
||||||
|
setStatusMessage,
|
||||||
|
tenantIdRef,
|
||||||
|
mapDocumentCaches,
|
||||||
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
correspondentLookupByName,
|
correspondentLookupByName,
|
||||||
handleDocumentCorrespondentAttach,
|
handleDocumentCorrespondentAttach,
|
||||||
handleCorrespondentRemove,
|
handleCorrespondentRemove,
|
||||||
handleCorrespondentAdd,
|
handleCorrespondentAdd,
|
||||||
|
} = useDocumentCorrespondentActions({
|
||||||
|
correspondents,
|
||||||
|
handleCorrespondentCreate,
|
||||||
|
notifyApiError,
|
||||||
|
setStatusMessage,
|
||||||
|
updateDocumentCaches,
|
||||||
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
passkeys,
|
passkeys,
|
||||||
passkeysSupported,
|
passkeysSupported,
|
||||||
passkeysLoading,
|
passkeysLoading,
|
||||||
@@ -503,15 +546,9 @@ const useDocumentsWorkspace = ({
|
|||||||
refreshPasskeys,
|
refreshPasskeys,
|
||||||
registerPasskey,
|
registerPasskey,
|
||||||
revokePasskey,
|
revokePasskey,
|
||||||
} = useWorkspaceTaxonomies({
|
} = usePasskeys({
|
||||||
notifyApiError,
|
notifyApiError,
|
||||||
setStatusMessage,
|
setStatusMessage,
|
||||||
tagManager,
|
|
||||||
tenantIdRef,
|
|
||||||
currentTenantId,
|
|
||||||
setActiveTagFilters,
|
|
||||||
mapDocumentCaches,
|
|
||||||
updateDocumentCaches,
|
|
||||||
token,
|
token,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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<Identifier | null>;
|
|
||||||
currentTenantId: Identifier | null;
|
|
||||||
setActiveTagFilters: Dispatch<SetStateAction<Identifier[]>>;
|
|
||||||
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;
|
|
||||||
Reference in New Issue
Block a user