diff --git a/apps/photos/src/components/LivePhotoBtn.tsx b/apps/photos/src/components/LivePhotoBtn.tsx deleted file mode 100644 index bb1976db9..000000000 --- a/apps/photos/src/components/LivePhotoBtn.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; - -export const livePhotoBtnHTML = ( - - - - -); diff --git a/apps/photos/src/components/PhotoFrame.tsx b/apps/photos/src/components/PhotoFrame.tsx index 838db20b3..0459b3dfc 100644 --- a/apps/photos/src/components/PhotoFrame.tsx +++ b/apps/photos/src/components/PhotoFrame.tsx @@ -13,7 +13,6 @@ import { MergedSourceURL, SelectedState } from 'types/gallery'; import PublicCollectionDownloadManager from 'services/publicCollectionDownloadManager'; import { PublicCollectionGalleryContext } from 'utils/publicCollectionGallery'; import { useRouter } from 'next/router'; -import { AppContext } from 'pages/_app'; import { logError } from 'utils/sentry'; import { addLogLine } from 'utils/logging'; import PhotoSwipe from 'photoswipe'; @@ -75,7 +74,6 @@ const PhotoFrame = ({ const [currentIndex, setCurrentIndex] = useState(0); const [fetching, setFetching] = useState<{ [k: number]: boolean }>({}); const galleryContext = useContext(GalleryContext); - const appContext = useContext(AppContext); const publicCollectionGalleryContext = useContext( PublicCollectionGalleryContext ); @@ -468,7 +466,6 @@ const PhotoFrame = ({ addLogLine( `[${item.id}] gallery context cache miss, calling downloadManager to get file` ); - appContext.startLoading(); let downloadedURL: { original: string[]; converted: string[]; @@ -484,7 +481,6 @@ const PhotoFrame = ({ } else { downloadedURL = await DownloadManager.getFile(item, true); } - appContext.finishLoading(); const mergedURL: MergedSourceURL = { original: downloadedURL.original.join(','), converted: downloadedURL.converted.join(','), diff --git a/apps/photos/src/components/PhotoViewer/index.tsx b/apps/photos/src/components/PhotoViewer/index.tsx index 580e69c16..6278f9d88 100644 --- a/apps/photos/src/components/PhotoViewer/index.tsx +++ b/apps/photos/src/components/PhotoViewer/index.tsx @@ -13,7 +13,6 @@ import { getFileExtension, getFileFromURL, } from 'utils/file'; -import { livePhotoBtnHTML } from 'components/LivePhotoBtn'; import { logError } from 'utils/sentry'; import { FILE_TYPE } from 'constants/file'; @@ -26,7 +25,7 @@ import { defaultLivePhotoDefaultOptions, photoSwipeV4Events, } from 'constants/photoViewer'; -import { LivePhotoBtn } from './styledComponents/LivePhotoBtn'; +import { LivePhotoBtnContainer } from './styledComponents/LivePhotoBtn'; import DownloadIcon from '@mui/icons-material/Download'; import InfoIcon from '@mui/icons-material/InfoOutlined'; import FavoriteIcon from '@mui/icons-material/FavoriteRounded'; @@ -35,7 +34,7 @@ import ChevronRight from '@mui/icons-material/ChevronRight'; import DeleteIcon from '@mui/icons-material/Delete'; import { trashFiles } from 'services/fileService'; import { getTrashFileMessage } from 'utils/ui'; -import { styled } from '@mui/material'; +import { Box, Button, styled } from '@mui/material'; import { addLocalLog } from 'utils/logging'; import ContentCopy from '@mui/icons-material/ContentCopy'; import ChevronLeft from '@mui/icons-material/ChevronLeft'; @@ -44,7 +43,13 @@ import { getParsedExifData } from 'services/upload/exifService'; import { getFileType } from 'services/typeDetectionService'; import { ConversionFailedNotification } from './styledComponents/ConversionFailedNotification'; import { GalleryContext } from 'pages/gallery'; -import { ConvertBtn } from './styledComponents/ConvertBtn'; +import { ConvertBtnContainer } from './styledComponents/ConvertBtn'; +import downloadManager from 'services/downloadManager'; +import publicCollectionDownloadManager from 'services/publicCollectionDownloadManager'; +import CircularProgressWithLabel from './styledComponents/CircularProgressWithLabel'; +import EnteSpinner from 'components/EnteSpinner'; +import AlbumOutlined from '@mui/icons-material/AlbumOutlined'; +import { FlexWrapper } from 'components/Container'; interface PhotoswipeFullscreenAPI { enter: () => void; @@ -117,6 +122,20 @@ function PhotoViewer(props: Iprops) { setConversionFailedNotificationOpen, ] = useState(false); + const [fileDownloadProgress, setFileDownloadProgress] = useState< + Map + >(new Map()); + + useEffect(() => { + if (publicCollectionGalleryContext.accessedThroughSharedURL) { + publicCollectionDownloadManager.setProgressUpdater( + setFileDownloadProgress + ); + } else { + downloadManager.setProgressUpdater(setFileDownloadProgress); + } + }, []); + useEffect(() => { if (!pswpElement) return; if (isOpen) { @@ -599,13 +618,18 @@ function PhotoViewer(props: Iprops) {
{livePhotoBtnOptions.visible && ( - - {livePhotoBtnHTML} {t('LIVE')} - + + + )} downloadFileHelper(photoSwipe.currItem)} /> {showConvertBtn && ( - - {t('CONVERT')} - + + + )} + + {fileDownloadProgress.has( + (photoSwipe?.currItem as EnteFile)?.id + ) ? ( + + ) : ( + !isSourceLoaded && + )} + +
diff --git a/apps/photos/src/components/PhotoViewer/styledComponents/CircularProgressWithLabel.tsx b/apps/photos/src/components/PhotoViewer/styledComponents/CircularProgressWithLabel.tsx new file mode 100644 index 000000000..8b47f1101 --- /dev/null +++ b/apps/photos/src/components/PhotoViewer/styledComponents/CircularProgressWithLabel.tsx @@ -0,0 +1,32 @@ +import { + CircularProgressProps, + CircularProgress, + Typography, +} from '@mui/material'; +import { Overlay } from 'components/Container'; + +function CircularProgressWithLabel( + props: CircularProgressProps & { value: number } +) { + return ( + <> + + + {`${Math.round( + props.value + )}%`} + + + ); +} + +export default CircularProgressWithLabel; diff --git a/apps/photos/src/components/PhotoViewer/styledComponents/ConvertBtn.tsx b/apps/photos/src/components/PhotoViewer/styledComponents/ConvertBtn.tsx index ca31c3058..ce078919c 100644 --- a/apps/photos/src/components/PhotoViewer/styledComponents/ConvertBtn.tsx +++ b/apps/photos/src/components/PhotoViewer/styledComponents/ConvertBtn.tsx @@ -1,14 +1,9 @@ -import { Button, ButtonProps, styled } from '@mui/material'; -export const ConvertBtn = styled((props: ButtonProps) => ( -