From 3fc66ce2020178e8a2c4a867182c81ce2fba47be Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 10 Sep 2024 12:07:57 +0530 Subject: [PATCH] Bespoke --- web/apps/photos/src/pages/shared-albums.tsx | 105 +++++++++++++------- 1 file changed, 67 insertions(+), 38 deletions(-) diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsx index 60d833205b..e3f302a650 100644 --- a/web/apps/photos/src/pages/shared-albums.tsx +++ b/web/apps/photos/src/pages/shared-albums.tsx @@ -1,6 +1,6 @@ import { NavbarBase, SelectionBar } from "@/base/components/Navbar"; import { sharedCryptoWorker } from "@/base/crypto"; -import { useIsTouchscreen } from "@/base/hooks"; +import { useIsMobileWidth, useIsTouchscreen } from "@/base/hooks"; import log from "@/base/log"; import downloadManager from "@/new/photos/services/download"; import { EnteFile } from "@/new/photos/types/file"; @@ -27,6 +27,7 @@ import CloseIcon from "@mui/icons-material/Close"; import DownloadIcon from "@mui/icons-material/Download"; import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined"; import MoreHoriz from "@mui/icons-material/MoreHoriz"; +import type { ButtonProps, IconButtonProps } from "@mui/material"; import { Box, Button, IconButton, Stack, Tooltip } from "@mui/material"; import Typography from "@mui/material/Typography"; import bs58 from "bs58"; @@ -62,6 +63,7 @@ import { syncPublicFiles, verifyPublicCollectionPassword, } from "services/publicCollectionService"; +import uploadManager from "services/upload/uploadManager"; import { Collection } from "types/collection"; import { SelectedState, @@ -170,9 +172,11 @@ export default function PublicCollectionGallery() { return updater; }; - const openUploader = () => { - setUploadTypeSelectorView(true); - }; + const onAddPhotos = useMemo(() => { + return publicCollection?.publicURLs?.[0]?.enableCollect + ? () => setUploadTypeSelectorView(true) + : undefined; + }, [publicCollection]); const closeUploadTypeSelectorView = () => { setUploadTypeSelectorView(false); @@ -331,26 +335,26 @@ export default function PublicCollectionGallery() { }, [publicCollection, publicFiles]); useEffect(() => { - if (publicCollection?.publicURLs?.[0]?.enableCollect) { - setPhotoListFooter({ - item: ( - - } - /> - - ), - itemType: ITEM_TYPE.FOOTER, - height: 104, - }); - } else { - setPhotoListFooter(null); - } - }, [publicCollection]); + setPhotoListFooter( + onAddPhotos + ? { + item: ( + + } + /> + + ), + itemType: ITEM_TYPE.FOOTER, + height: 104, + } + : null, + ); + }, [onAddPhotos]); const syncWithRemote = async () => { const collectionUID = getPublicCollectionUID(token.current); @@ -551,12 +555,7 @@ export default function PublicCollectionGallery() { getFolderSelectorInputProps, }} /> - + | undefined; +} +const SharedAlbumNavbar: React.FC = ({ + onAddPhotos, +}) => { return ( - {showUploadButton ? ( - } - text={t("ADD_PHOTOS")} - /> + {onAddPhotos ? ( + ) : ( )} ); -} +}; const EnteLinkLogo: React.FC = () => { return ( @@ -648,6 +651,32 @@ const EnteLinkLogo: React.FC = () => { ); }; +const AddPhotosButton: React.FC = (props) => { + const disabled = !uploadManager.shouldAllowNewUpload(); + const isMobileWidth = useIsMobileWidth(); + + const icon = ; + + return ( + + {isMobileWidth ? ( + + {icon} + + ) : ( + + )} + + ); +}; + const GoToEnte: React.FC = () => { // Touchscreen devices are overwhemingly likely to be Android or iOS. const isTouchscreen = useIsTouchscreen();