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