1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 00:20:07 +00:00

fix: gallery info toggle (#6945)

Co-authored-by: 杨国璇 <ygx@Hello-word.local>
This commit is contained in:
杨国璇
2024-10-25 17:03:49 +08:00
committed by GitHub
parent 0f6e34f771
commit 0a8ba80d42
3 changed files with 13 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect, useMemo } from 'react';
import PropTypes from 'prop-types';
import LibDetail from './lib-details';
import DirentDetail from './dirent-details';
@@ -8,9 +8,10 @@ import { MetadataContext } from '../../metadata';
import { PRIVATE_FILE_TYPE } from '../../constants';
const DetailContainer = React.memo(({ repoID, path, dirent, currentRepoInfo, repoTags, fileTags, onClose, onFileTagChanged }) => {
const isView = useMemo(() => path.startsWith('/' + PRIVATE_FILE_TYPE.FILE_EXTENDED_PROPERTIES), [path]);
useEffect(() => {
if (path.startsWith('/' + PRIVATE_FILE_TYPE.FILE_EXTENDED_PROPERTIES)) return;
if (isView) return;
// init context
const context = new MetadataContext();
@@ -22,12 +23,11 @@ const DetailContainer = React.memo(({ repoID, path, dirent, currentRepoInfo, rep
delete window['sfMetadataContext'];
}
};
}, [repoID, currentRepoInfo, path]);
}, [repoID, currentRepoInfo, isView]);
if (path.startsWith('/' + PRIVATE_FILE_TYPE.FILE_EXTENDED_PROPERTIES)) {
if (isView) {
const viewId = path.split('/').pop();
if (!dirent) return (<ViewDetails viewId={viewId} onClose={onClose} />);
path = dirent.path;
}
if (path === '/' && !dirent) {
@@ -41,7 +41,7 @@ const DetailContainer = React.memo(({ repoID, path, dirent, currentRepoInfo, rep
return (
<DirentDetail
repoID={repoID}
path={path}
path={isView ? dirent.path : path}
dirent={dirent}
currentRepoInfo={currentRepoInfo}
repoTags={repoTags}