Skip to content

Commit

Permalink
clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouwenxuan authored and zhouwenxuan committed Oct 11, 2024
1 parent 06efd19 commit fce1b53
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 3 additions & 2 deletions frontend/src/metadata/components/gallery-details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const GalleryDetail = ({ currentRepoInfo, viewID, onClose }) => {
const [repo, setRepo] = useState({});
const [direntDetail, setDirentDetail] = useState(null);
const { viewsMap, currentImage } = useMetadata();

const view = useMemo(() => viewsMap[viewID], [viewID, viewsMap]);
const icon = useMemo(() => Utils.getFolderIconUrl(), []);
const filesField = useMemo(() => ({ type: CellType.NUMBER, name: gettext('Files') }), []);
Expand Down Expand Up @@ -89,8 +90,8 @@ const GalleryDetail = ({ currentRepoInfo, viewID, onClose }) => {
}) : null;
}, [currentImage]);

const smallIconUrl = dirent ? Utils.getDirentIcon(dirent) : '';
const bigIconUrl = dirent ? `${siteRoot}thumbnail/${currentRepoInfo.repo_id}/${thumbnailSizeForGrid}` + Utils.encodePath(`${currentImage.path === '/' ? '' : currentImage.path}/${dirent.name}`) : '';
const smallIconUrl = useMemo(() => dirent ? Utils.getDirentIcon(dirent) : '', [dirent]);
const bigIconUrl = useMemo(() => dirent ? `${siteRoot}thumbnail/${currentRepoInfo.repo_id}/${thumbnailSizeForGrid}${Utils.encodePath(`${currentImage.path === '/' ? '' : currentImage.path}/${dirent.name}`)}` : '', [dirent, currentRepoInfo.repo_id, currentImage]);

const renderGalleryInfo = () => (
<Detail>
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/metadata/views/gallery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@ const Gallery = () => {
let init = metadata.rows.filter(row => Utils.imageCheck(getFileNameFromRecord(row)))
.reduce((_init, record) => {
const id = record[PRIVATE_COLUMN_KEY.ID];
const obj_id = record[PRIVATE_COLUMN_KEY.OBJ_ID];
const fileName = getFileNameFromRecord(record);
const parentDir = getParentDirFromRecord(record);
const path = Utils.encodePath(Utils.joinPath(parentDir, fileName));
const date = mode !== GALLERY_DATE_MODE.ALL ? getDateDisplayString(record[firstSort.column_key], dateMode) : '';
const img = {
id,
obj_id,
name: fileName,
path: parentDir,
url: `${siteRoot}lib/${repoID}/file${path}`,
Expand Down

0 comments on commit fce1b53

Please sign in to comment.