diff --git a/web/apps/photos/src/components/PhotoViewer/index.tsx b/web/apps/photos/src/components/PhotoViewer/index.tsx index 127f84073b..b6473bd737 100644 --- a/web/apps/photos/src/components/PhotoViewer/index.tsx +++ b/web/apps/photos/src/components/PhotoViewer/index.tsx @@ -81,9 +81,9 @@ export type PhotoViewerProps = Pick< isTrashCollection: boolean; isInHiddenSection: boolean; enableDownload: boolean; + setFilesDownloadProgressAttributesCreator: SetFilesDownloadProgressAttributesCreator; fileToCollectionsMap: Map; collectionNameMap: Map; - setFilesDownloadProgressAttributesCreator: SetFilesDownloadProgressAttributesCreator; onSelectPerson?: FileInfoProps["onSelectPerson"]; }; @@ -105,10 +105,19 @@ export const PhotoViewer: React.FC = (props) => { id, isOpen, items, + currentIndex, + onClose, forceConvertItem, favoriteFileIDs, markUnsyncedFavoriteUpdate, markTempDeleted, + isTrashCollection, + isInHiddenSection, + enableDownload, + setFilesDownloadProgressAttributesCreator, + fileToCollectionsMap, + collectionNameMap, + onSelectPerson, } = props; const galleryContext = useContext(GalleryContext); @@ -371,7 +380,6 @@ export const PhotoViewer: React.FC = (props) => { } const openPhotoSwipe = () => { - const { items, currentIndex } = props; const options = { history: false, maxSpreadZoom: 5, @@ -465,7 +473,6 @@ export const PhotoViewer: React.FC = (props) => { }; const handleClose = () => { - const { onClose } = props; if (typeof onClose === "function") { onClose(needUpdate.current); } @@ -478,12 +485,7 @@ export const PhotoViewer: React.FC = (props) => { const handleFavoriteClick = () => { const file = photoSwipe?.currItem as EnteFile; - if ( - !file || - props.isTrashCollection || - !isOwnFile || - props.isInHiddenSection - ) { + if (!file || isTrashCollection || !isOwnFile || isInHiddenSection) { assertionFailed(); return; } @@ -518,7 +520,7 @@ export const PhotoViewer: React.FC = (props) => { hideLoadingBar(); } markTempDeleted?.([file]); - updateItems(props.items.filter((item) => item.id !== file.id)); + updateItems(items.filter((item) => item.id !== file.id)); needUpdate.current = true; } catch (e) { log.error("trashFile failed", e); @@ -526,7 +528,7 @@ export const PhotoViewer: React.FC = (props) => { }; const confirmTrashFile = (file: EnteFile) => { - if (!file || !isOwnFile || props.isTrashCollection) { + if (!file || !isOwnFile || isTrashCollection) { return; } showMiniDialog({ @@ -656,12 +658,12 @@ export const PhotoViewer: React.FC = (props) => { const downloadFileHelper = async (file: EnteFile) => { if ( file && - props.enableDownload && - props.setFilesDownloadProgressAttributesCreator + enableDownload && + setFilesDownloadProgressAttributesCreator ) { try { const setSingleFileDownloadProgress = - props.setFilesDownloadProgressAttributesCreator( + setFilesDownloadProgressAttributesCreator( file.metadata.title, ); await downloadSingleFile(file, setSingleFileDownloadProgress); @@ -672,7 +674,7 @@ export const PhotoViewer: React.FC = (props) => { }; const copyToClipboardHelper = async (file: DisplayFile) => { - if (file && props.enableDownload && shouldShowCopyOption) { + if (file && enableDownload && shouldShowCopyOption) { showLoadingBar(); await copyFileToClipboard(file.src); hideLoadingBar(); @@ -809,7 +811,7 @@ export const PhotoViewer: React.FC = (props) => { - {props.enableDownload && ( + {enableDownload && ( )} - {props.enableDownload && shouldShowCopyOption && ( + {enableDownload && shouldShowCopyOption && ( )} - {isOwnFile && !props.isTrashCollection && ( + {isOwnFile && !isTrashCollection && ( {isOwnFile && - !props.isTrashCollection && - !props.isInHiddenSection && ( + !isTrashCollection && + !isInHiddenSection && ( <> {showEditButton && (