Skip to content

Commit

Permalink
show video thumbnail in gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouwenxuan authored and 杨国璇 committed Nov 18, 2024
1 parent 3b384be commit 231158e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions frontend/src/metadata/views/gallery/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import './index.css';

const OVER_SCAN_ROWS = 20;

const Main = ({ isLoadingMore, metadata, onDelete, onLoadMore }) => {
const Main = ({ isLoadingMore, onDelete, onLoadMore }) => {
const [isFirstLoading, setFirstLoading] = useState(true);
const [zoomGear, setZoomGear] = useState(0);
const [containerWidth, setContainerWidth] = useState(0);
Expand All @@ -36,7 +36,7 @@ const Main = ({ isLoadingMore, metadata, onDelete, onLoadMore }) => {
const lastState = useRef({ visibleAreaFirstImage: { groupIndex: 0, rowIndex: 0 } });

const repoID = window.sfMetadataContext.getSetting('repoID');
const { updateCurrentDirent } = useMetadataView();
const { metadata, updateCurrentDirent } = useMetadataView();

useEffect(() => {
updateCurrentDirent();
Expand Down Expand Up @@ -68,7 +68,7 @@ const Main = ({ isLoadingMore, metadata, onDelete, onLoadMore }) => {
const groups = useMemo(() => {
if (isFirstLoading) return [];
const firstSort = metadata.view.sorts[0];
let init = metadata.rows.filter(row => Utils.imageCheck(getFileNameFromRecord(row)))
let init = metadata.rows.filter(row => Utils.imageCheck(getFileNameFromRecord(row)) || Utils.videoCheck(getFileNameFromRecord(row)))
.reduce((_init, record) => {
const id = record[PRIVATE_COLUMN_KEY.ID];
const fileName = getFileNameFromRecord(record);
Expand Down Expand Up @@ -262,10 +262,17 @@ const Main = ({ isLoadingMore, metadata, onDelete, onLoadMore }) => {
}, [imageItems, selectedImages, updateSelectedImage]);

const handleDoubleClick = useCallback((event, image) => {
const index = imageItems.findIndex(item => item.id === image.id);
setImageIndex(index);
setIsImagePopupOpen(true);
}, [imageItems]);
const isImageFile = Utils.imageCheck(image.name);
if (isImageFile) {
const index = imageItems.findIndex(item => item.id === image.id);
setImageIndex(index);
setIsImagePopupOpen(true);
} else {
const direntPath = Utils.joinPath(image.path, image.name);
const url = `${siteRoot}lib/${repoID}/file${Utils.encodePath(direntPath)}`;
window.open(url);
}
}, [imageItems, repoID]);

const handleRightClick = useCallback((event, image) => {
event.preventDefault();
Expand Down

0 comments on commit 231158e

Please sign in to comment.