π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Extract and merge, part 1
Manav Rathid327eb027c4f
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsxindex 48e32abce6..1bf7574f06 100644--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx@@ -62,8 +62,8 @@ type GalleryBarAndListHeaderProps = Omit<* dialogs that might be triggered by actions on either the bar or the header..** This component manages the sticky horizontally scrollable bar shown at the- * top of the gallery, AND the non-sticky header shown below the bar, at the top- * of the actual list of items.+ * top of the gallery, AND the (non-sticky) header shown below the bar, at the+ * top of the actual list of items.** These are disparate views - indeed, the list header is not even a child of* this component but is instead proxied via {@link setFileListHeader}. Still,diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 6fb596b991..dbb6f1425c 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -180,9 +180,6 @@ const Page: React.FC = () => {const [fixCreationTimeFiles, setFixCreationTimeFiles] = useState<EnteFile[]>([]);- /**- * The (non-sticky) header shown at the top of the gallery items.- */const [fileListHeader, setFileListHeader] = useState<FileListHeaderOrFooter | undefined>(undefined);diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsxindex 52a2aabc8e..ea565c7adb 100644--- a/web/apps/photos/src/pages/shared-albums.tsx+++ b/web/apps/photos/src/pages/shared-albums.tsx@@ -390,7 +390,7 @@ export default function PublicCollectionGallery() {publicCollection && publicFiles? {item: (- <ListHeader+ <FileListHeader{...{publicCollection,publicFiles,@@ -398,26 +398,19 @@ export default function PublicCollectionGallery() {}}/>),- height: 68,+ height: fileListHeaderHeight,}: undefined,[onAddSaveGroup, publicCollection, publicFiles],);- const fileListFooter = useMemo(- () =>- onAddPhotos- ? {- item: (- <CenteredFill sx={{ marginTop: "56px" }}>- <AddMorePhotosButton onClick={onAddPhotos} />- </CenteredFill>- ),- height: 104,- }- : undefined,- [onAddPhotos],- );+ const fileListFooter = useMemo(() => {+ const props = { referralCode: referralCode.current, onAddPhotos };+ return {+ item: <FileListFooter {...props} />,+ height: fileListFooterHeightForProps(props),+ };+ }, [referralCode.current, onAddPhotos]);if (loading && (!publicFiles || !credentials.current)) {return <LoadingIndicator />;@@ -626,13 +619,24 @@ const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({</Stack>);-interface ListHeaderProps {+interface FileListHeaderProps {publicCollection: Collection;publicFiles: EnteFile[];onAddSaveGroup: AddSaveGroup;}-const ListHeader: React.FC<ListHeaderProps> = ({+/**+ * The fixed height (in px) of {@link FileListHeader}.+ */+const fileListHeaderHeight = 68;++/**+ * A header shown before the listing of files.+ *+ * It scrolls along with the content. It has a fixed height,+ * {@link fileListHeaderHeight}.+ */+const FileListHeader: React.FC<FileListHeaderProps> = ({publicCollection,publicFiles,onAddSaveGroup,@@ -670,3 +674,88 @@ const ListHeader: React.FC<ListHeaderProps> = ({</GalleryItemsHeaderAdapter>);};++interface FileListFooterProps {+ referralCode?: string;+ onAddPhotos?: () => void;+}++/**+ * The dynamic (prop-depedent) height of {@link FileListFooter}.+ */+const fileListFooterHeightForProps = ({+ referralCode,+ onAddPhotos,+}: FileListFooterProps) => (onAddPhotos ? 104 : 0) + (referralCode ? 113 : 75);++/**+ * A footer shown after the listing of files.+ *+ * It scrolls along with the content. It has a dynamic height, dependent on the+ * props, calculated using {@link fileListFooterHeightForProps}.+ */++const FileListFooter: React.FC<FileListFooterProps> = ({+ referralCode,+ onAddPhotos,+}) => {+ if (onAddPhotos)+ return (+ <CenteredFill sx={{ marginTop: "56px" }}>+ <AddMorePhotosButton onClick={onAddPhotos} />+ </CenteredFill>+ );++ return (+ <AlbumFooterContainer+ span={columns}+ hasReferral={!!publicCollectionGalleryContext.referralCode}+ >+ {/* Make the entire area tappable, otherwise it is hard to+ get at on mobile devices. */}+ <Box sx={{ width: "100%" }}>+ <Link+ color="text.base"+ sx={{ "&:hover": { color: "inherit" } }}+ target="_blank"+ href={"https://ente.io"}+ >+ <Typography variant="small">+ <Trans+ i18nKey="shared_using"+ components={{+ a: (+ <Typography+ variant="small"+ component="span"+ sx={{ color: "accent.main" }}+ />+ ),+ }}+ values={{ url: "ente.io" }}+ />+ </Typography>+ </Link>+ {publicCollectionGalleryContext.referralCode ? (+ <FullStretchContainer>+ <Typography+ sx={{+ marginTop: "12px",+ padding: "8px",+ color: "accent.contrastText",+ }}+ >+ <Trans+ i18nKey={"sharing_referral_code"}+ values={{+ referralCode:+ publicCollectionGalleryContext.referralCode,+ }}+ />+ </Typography>+ </FullStretchContainer>+ ) : null}+ </Box>+ </AlbumFooterContainer>+ );+};diff --git a/web/packages/new/photos/components/gallery/ListHeader.tsx b/web/packages/new/photos/components/gallery/ListHeader.tsxindex 91838f3852..1979ff5fe5 100644--- a/web/packages/new/photos/components/gallery/ListHeader.tsx+++ b/web/packages/new/photos/components/gallery/ListHeader.tsx@@ -38,8 +38,8 @@ interface GalleryItemsSummaryProps {}/**- * A component suitable for being used as a (non-sticky) summary displayed on- * top of the of a list of photos (or other items) shown in the gallery.+ * A component suitable for being used as a summary displayed on top of the of a+ * list of photos (or other items) shown in the gallery.*/export const GalleryItemsSummary: React.FC<GalleryItemsSummaryProps> = ({name,