Remove asset/document hydration pipeline and introduce client-side cache updates for correspondents, tags, and search results
This commit is contained in:
@@ -318,9 +318,6 @@ const useDocumentsWorkspace = ({
|
||||
} = useDocuments({
|
||||
setFolderContents,
|
||||
fetchDocumentById,
|
||||
hydrateDocument: (payload) => assetManager.hydrateDocument(payload),
|
||||
hydrateDocuments: (payload) => assetManager.hydrateDocuments(payload),
|
||||
extractDocument: extractDocumentFromResponse,
|
||||
});
|
||||
|
||||
const documentLookup = useSyncExternalStore(
|
||||
@@ -348,7 +345,6 @@ const useDocumentsWorkspace = ({
|
||||
isInvalidFolderDrop,
|
||||
} = useFolderTree({
|
||||
initialSelectedFolder: routeFolderId || 'root',
|
||||
assetManager,
|
||||
apiClient: api,
|
||||
tenantIdRef,
|
||||
documentsSortFieldRef: activeSortFieldRef,
|
||||
@@ -370,6 +366,7 @@ const useDocumentsWorkspace = ({
|
||||
activeCorrespondentFilters,
|
||||
setActiveCorrespondentFilters,
|
||||
isFilterActive,
|
||||
refetchSearchResults,
|
||||
documentsFilterValue,
|
||||
} = useDocumentsSearch({
|
||||
api,
|
||||
@@ -444,7 +441,6 @@ const useDocumentsWorkspace = ({
|
||||
|
||||
const {
|
||||
documentLinks,
|
||||
ensurePreviewData,
|
||||
ensureDownloadUrl,
|
||||
openDocumentPreview,
|
||||
closeDocumentPreview,
|
||||
@@ -454,7 +450,6 @@ const useDocumentsWorkspace = ({
|
||||
routeDocumentId: previewDocumentId,
|
||||
documentsManager,
|
||||
selectedFolder,
|
||||
assetManager,
|
||||
api,
|
||||
resolveApiPath,
|
||||
notifyApiError,
|
||||
@@ -607,6 +602,14 @@ const useDocumentsWorkspace = ({
|
||||
}
|
||||
}, [selectedFolder, ensureFolderData, applySelectedFolder, notifyApiError]);
|
||||
|
||||
const refreshVisibleDocuments = useCallback(async () => {
|
||||
if (showingSearchResults) {
|
||||
await refetchSearchResults();
|
||||
return;
|
||||
}
|
||||
await refreshCurrentFolder();
|
||||
}, [showingSearchResults, refetchSearchResults, refreshCurrentFolder]);
|
||||
|
||||
const {
|
||||
handleBulkTagAddFromDetail,
|
||||
handleBulkTagRemoveFromDetail,
|
||||
@@ -616,11 +619,11 @@ const useDocumentsWorkspace = ({
|
||||
tags,
|
||||
tagManager,
|
||||
refreshTags,
|
||||
refreshCurrentFolder,
|
||||
resolveTargetDocumentIds,
|
||||
notifyApiError,
|
||||
setStatusMessage,
|
||||
setLoading,
|
||||
updateDocumentCaches,
|
||||
});
|
||||
|
||||
const {
|
||||
@@ -671,9 +674,9 @@ const useDocumentsWorkspace = ({
|
||||
apiClient: api,
|
||||
correspondents,
|
||||
handleCorrespondentCreate,
|
||||
refreshCurrentFolder,
|
||||
notifyApiError,
|
||||
setStatusMessage,
|
||||
updateDocumentCaches,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@@ -851,6 +854,7 @@ const useDocumentsWorkspace = ({
|
||||
closeDocumentPreview,
|
||||
previewDocumentId,
|
||||
refreshCurrentFolder,
|
||||
refreshVisibleDocuments,
|
||||
documentsViewMode,
|
||||
updateDocumentCaches,
|
||||
tagLookupById,
|
||||
@@ -858,6 +862,7 @@ const useDocumentsWorkspace = ({
|
||||
refreshTags,
|
||||
tagManager,
|
||||
extractDocumentFromResponse,
|
||||
ingestDocuments: (docs) => documentsManager.ingest(docs),
|
||||
});
|
||||
|
||||
const {
|
||||
@@ -1007,7 +1012,6 @@ const useDocumentsWorkspace = ({
|
||||
resolveTargetDocumentIds,
|
||||
correspondentLookupByName,
|
||||
handleCorrespondentCreate,
|
||||
refreshCurrentFolder,
|
||||
setStatusMessage,
|
||||
selectedDocumentIds,
|
||||
selectedFolderIds,
|
||||
@@ -1015,6 +1019,7 @@ const useDocumentsWorkspace = ({
|
||||
handleFolderDelete,
|
||||
clearDocumentSelection,
|
||||
setLoading,
|
||||
updateDocumentCaches,
|
||||
});
|
||||
|
||||
|
||||
@@ -1036,9 +1041,7 @@ const useDocumentsWorkspace = ({
|
||||
return null;
|
||||
}
|
||||
|
||||
setDocuments((prev) =>
|
||||
prev.map((doc) => (doc.id === documentId ? mergeAssetIntoDocument(doc, entry) : doc)),
|
||||
);
|
||||
updateDocumentCaches(documentId, (doc) => mergeAssetIntoDocument(doc, entry));
|
||||
|
||||
return entry;
|
||||
} catch (error) {
|
||||
@@ -1046,7 +1049,7 @@ const useDocumentsWorkspace = ({
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
[assetManager, setDocuments, notifyApiError],
|
||||
[assetManager, updateDocumentCaches, notifyApiError],
|
||||
);
|
||||
|
||||
|
||||
@@ -1264,7 +1267,6 @@ const useDocumentsWorkspace = ({
|
||||
handleTagRemove,
|
||||
ensureAssetUrl,
|
||||
getDocumentAsset,
|
||||
ensurePreviewData,
|
||||
correspondents,
|
||||
handleCorrespondentAdd,
|
||||
handleCorrespondentRemove,
|
||||
@@ -1617,7 +1619,6 @@ const useDocumentsWorkspace = ({
|
||||
documentsTableProps,
|
||||
detailPanelProps,
|
||||
documentsViewMode,
|
||||
ensurePreviewData,
|
||||
ensureAssetUrl,
|
||||
resolveFolderPath,
|
||||
getDocumentAsset,
|
||||
@@ -1669,7 +1670,6 @@ const useDocumentsWorkspace = ({
|
||||
documentsTableProps,
|
||||
detailPanelProps,
|
||||
documentsViewMode,
|
||||
ensurePreviewData,
|
||||
ensureAssetUrl,
|
||||
resolveFolderPath,
|
||||
getDocumentAsset,
|
||||
|
||||
Reference in New Issue
Block a user