cleanup
This commit is contained in:
@@ -316,6 +316,7 @@ const AppLayout = () => {
|
||||
const [searchResults, setSearchResults] = useState(null);
|
||||
const [previewEntries, setPreviewEntries] = useState(() => new Map());
|
||||
const previewInflightRef = useRef(new Map());
|
||||
const previewReturnPathRef = useRef(null);
|
||||
const [tags, setTags] = useState([]);
|
||||
const [correspondents, setCorrespondents] = useState([]);
|
||||
const [webdavTokens, setWebdavTokens] = useState([]);
|
||||
@@ -3358,10 +3359,10 @@ const AppLayout = () => {
|
||||
});
|
||||
}
|
||||
|
||||
const targetFolder = doc?.folder_id || selectedFolder || 'root';
|
||||
if (targetFolder && targetFolder !== selectedFolder) {
|
||||
await loadFolder(targetFolder, { showLoading: false, preserveSearch: isFilterActive });
|
||||
doc = findInCache() || doc;
|
||||
if (!previewReturnPathRef.current) {
|
||||
const fallbackFolderId = doc?.folder_id || 'root';
|
||||
previewReturnPathRef.current =
|
||||
fallbackFolderId === 'root' ? '/documents' : `/documents/folder/${fallbackFolderId}`;
|
||||
}
|
||||
|
||||
await ensurePreviewUrl(documentId, { force: false });
|
||||
@@ -3373,9 +3374,6 @@ const AppLayout = () => {
|
||||
documents,
|
||||
assetManager,
|
||||
setDocuments,
|
||||
selectedFolder,
|
||||
loadFolder,
|
||||
isFilterActive,
|
||||
ensurePreviewUrl,
|
||||
setActivePreviewId,
|
||||
],
|
||||
@@ -3384,13 +3382,22 @@ const AppLayout = () => {
|
||||
const openDocumentPreview = useCallback(
|
||||
(documentId, { replace = false } = {}) => {
|
||||
if (!documentId) return;
|
||||
previewReturnPathRef.current = `${location.pathname}${location.search}`;
|
||||
navigate(`/documents/${documentId}`, { replace });
|
||||
},
|
||||
[navigate],
|
||||
[navigate, location.pathname, location.search],
|
||||
);
|
||||
|
||||
const closeDocumentPreview = useCallback(
|
||||
(folderId = null) => {
|
||||
const fallbackPath = previewReturnPathRef.current;
|
||||
previewReturnPathRef.current = null;
|
||||
|
||||
if (fallbackPath) {
|
||||
navigate(fallbackPath, { replace: false });
|
||||
return;
|
||||
}
|
||||
|
||||
const targetId = folderId || selectedFolder || 'root';
|
||||
const path = targetId === 'root' ? '/documents' : `/documents/folder/${targetId}`;
|
||||
navigate(path, { replace: false });
|
||||
|
||||
Reference in New Issue
Block a user