π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Inline
Manav Rathi15ae4a47a631
diff --git a/web/apps/photos/src/components/Collections/CollectionShare/index.tsx b/web/apps/photos/src/components/Collections/CollectionShare/index.tsxindex de646c588a..1901b4ed32 100644--- a/web/apps/photos/src/components/Collections/CollectionShare/index.tsx+++ b/web/apps/photos/src/components/Collections/CollectionShare/index.tsx@@ -15,6 +15,7 @@ import { PublicLinkCreated } from "@/new/photos/components/share/PublicLinkCreatimport type { CollectionSummary } from "@/new/photos/services/collection/ui";import { useAppContext } from "@/new/photos/types/context";import { EnteMenuItem } from "@ente/shared/components/Menu/EnteMenuItem";+import { formatDateTime } from "@ente/shared/time/format";import {default as ChevronRight,default as ChevronRightIcon,@@ -37,11 +38,11 @@ import { SetPublicShareProp } from "types/publicCollection";import {appendCollectionKeyToShareURL,getDeviceLimitOptions,+ shareExpiryOptions,} from "utils/collection";import { handleSharingErrors } from "utils/error/ui";import EmailShare from "./emailShare";import EnablePublicShareOptions from "./publicShare/EnablePublicShareOptions";-import { ManageLinkExpiry } from "./publicShare/manage/linkExpiry";import { ManageLinkPassword } from "./publicShare/manage/linkPassword";import SharingDetails from "./sharingDetails";@@ -183,10 +184,6 @@ const PublicShare: React.FC<PublicShareProps> = ({);};-export const isLinkExpired = (validTill: number) => {- return validTill && validTill < Date.now() * 1000;-};-interface ManagePublicShareProps {publicShareProp: PublicURL;collection: Collection;@@ -254,6 +251,10 @@ const ManagePublicShare: React.FC<ManagePublicShareProps> = ({);};+const isLinkExpired = (validTill: number) => {+ return validTill && validTill < Date.now() * 1000;+};+interface ManagePublicShareOptionsProps {publicShareProp: PublicURL;collection: Collection;@@ -572,3 +573,108 @@ const ManagePublicCollect: React.FC<ManagePublicCollectProps> = ({</Stack>);};++interface ManageLinkExpiryProps {+ publicShareProp: PublicURL;+ collection: Collection;+ updatePublicShareURLHelper: (req: UpdatePublicURL) => Promise<void>;+ onRootClose: () => void;+}++const ManageLinkExpiry: React.FC<ManageLinkExpiryProps> = ({+ publicShareProp,+ collection,+ updatePublicShareURLHelper,+ onRootClose,+}) => {+ const updateDeviceExpiry = async (optionFn) => {+ return updatePublicShareURLHelper({+ collectionID: collection.id,+ validTill: optionFn,+ });+ };++ const [shareExpiryOptionsModalView, setShareExpiryOptionsModalView] =+ useState(false);++ const shareExpireOption = useMemo(() => shareExpiryOptions(), []);++ const closeShareExpiryOptionsModalView = () =>+ setShareExpiryOptionsModalView(false);++ const openShareExpiryOptionsModalView = () =>+ setShareExpiryOptionsModalView(true);++ const changeShareExpiryValue = (value: number) => async () => {+ await updateDeviceExpiry(value);+ publicShareProp.validTill = value;+ setShareExpiryOptionsModalView(false);+ };++ const handleDrawerClose: DialogProps["onClose"] = (_, reason) => {+ if (reason === "backdropClick") {+ onRootClose();+ } else {+ closeShareExpiryOptionsModalView();+ }+ };++ return (+ <>+ <MenuItemGroup>+ <EnteMenuItem+ onClick={openShareExpiryOptionsModalView}+ endIcon={<ChevronRight />}+ variant="captioned"+ label={t("LINK_EXPIRY")}+ color={+ isLinkExpired(publicShareProp?.validTill)+ ? "critical"+ : "primary"+ }+ subText={+ isLinkExpired(publicShareProp?.validTill)+ ? t("link_expired")+ : publicShareProp?.validTill+ ? formatDateTime(+ publicShareProp?.validTill / 1000,+ )+ : t("never")+ }+ />+ </MenuItemGroup>+ <SidebarDrawer+ anchor="right"+ open={shareExpiryOptionsModalView}+ onClose={handleDrawerClose}+ >+ <Stack spacing={"4px"} py={"12px"}>+ <Titlebar+ onClose={closeShareExpiryOptionsModalView}+ title={t("LINK_EXPIRY")}+ onRootClose={onRootClose}+ />+ <Stack py={"20px"} px={"8px"} spacing={"32px"}>+ <MenuItemGroup>+ {shareExpireOption.map((item, index) => (+ <>+ <EnteMenuItem+ fontWeight="normal"+ key={item.value()}+ onClick={changeShareExpiryValue(+ item.value(),+ )}+ label={item.label}+ />+ {index !== shareExpireOption.length - 1 && (+ <MenuItemDivider />+ )}+ </>+ ))}+ </MenuItemGroup>+ </Stack>+ </Stack>+ </SidebarDrawer>+ </>+ );+};diff --git a/web/apps/photos/src/components/Collections/CollectionShare/publicShare/manage/linkExpiry.tsx b/web/apps/photos/src/components/Collections/CollectionShare/publicShare/manage/linkExpiry.tsxdeleted file mode 100644index efc2829470..0000000000--- a/web/apps/photos/src/components/Collections/CollectionShare/publicShare/manage/linkExpiry.tsx+++ /dev/null@@ -1,121 +0,0 @@-import { MenuItemDivider, MenuItemGroup } from "@/base/components/Menu";-import { SidebarDrawer } from "@/base/components/mui/SidebarDrawer";-import { Titlebar } from "@/base/components/Titlebar";-import type {- Collection,- PublicURL,- UpdatePublicURL,-} from "@/media/collection";-import { EnteMenuItem } from "@ente/shared/components/Menu/EnteMenuItem";-import { formatDateTime } from "@ente/shared/time/format";-import ChevronRight from "@mui/icons-material/ChevronRight";-import { DialogProps, Stack } from "@mui/material";-import { t } from "i18next";-import { useMemo, useState } from "react";-import { shareExpiryOptions } from "utils/collection";-import { isLinkExpired } from "../managePublicShare";--interface Iprops {- publicShareProp: PublicURL;- collection: Collection;- updatePublicShareURLHelper: (req: UpdatePublicURL) => Promise<void>;- onRootClose: () => void;-}--export function ManageLinkExpiry({- publicShareProp,- collection,- updatePublicShareURLHelper,- onRootClose,-}: Iprops) {- const updateDeviceExpiry = async (optionFn) => {- return updatePublicShareURLHelper({- collectionID: collection.id,- validTill: optionFn,- });- };-- const [shareExpiryOptionsModalView, setShareExpiryOptionsModalView] =- useState(false);-- const shareExpireOption = useMemo(() => shareExpiryOptions(), []);-- const closeShareExpiryOptionsModalView = () =>- setShareExpiryOptionsModalView(false);-- const openShareExpiryOptionsModalView = () =>- setShareExpiryOptionsModalView(true);-- const changeShareExpiryValue = (value: number) => async () => {- await updateDeviceExpiry(value);- publicShareProp.validTill = value;- setShareExpiryOptionsModalView(false);- };-- const handleDrawerClose: DialogProps["onClose"] = (_, reason) => {- if (reason === "backdropClick") {- onRootClose();- } else {- closeShareExpiryOptionsModalView();- }- };-- return (- <>- <MenuItemGroup>- <EnteMenuItem- onClick={openShareExpiryOptionsModalView}- endIcon={<ChevronRight />}- variant="captioned"- label={t("LINK_EXPIRY")}- color={- isLinkExpired(publicShareProp?.validTill)- ? "critical"- : "primary"- }- subText={- isLinkExpired(publicShareProp?.validTill)- ? t("link_expired")- : publicShareProp?.validTill- ? formatDateTime(- publicShareProp?.validTill / 1000,- )- : t("never")- }- />- </MenuItemGroup>- <SidebarDrawer- anchor="right"- open={shareExpiryOptionsModalView}- onClose={handleDrawerClose}- >- <Stack spacing={"4px"} py={"12px"}>- <Titlebar- onClose={closeShareExpiryOptionsModalView}- title={t("LINK_EXPIRY")}- onRootClose={onRootClose}- />- <Stack py={"20px"} px={"8px"} spacing={"32px"}>- <MenuItemGroup>- {shareExpireOption.map((item, index) => (- <>- <EnteMenuItem- fontWeight="normal"- key={item.value()}- onClick={changeShareExpiryValue(- item.value(),- )}- label={item.label}- />- {index !== shareExpireOption.length - 1 && (- <MenuItemDivider />- )}- </>- ))}- </MenuItemGroup>- </Stack>- </Stack>- </SidebarDrawer>- </>- );-}