π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat: add template selection option for public albums
anandbaburajanb3af4860663c
diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsxindex b23778551f..4f747d371e 100644--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx@@ -65,6 +65,7 @@ import {deleteShareURL,shareCollection,unshareCollection,+ updateCollectionTemplate,updatePublicURL,type CreatePublicURLAttributes,type UpdatePublicURLAttributes,@@ -1424,6 +1425,14 @@ const ManagePublicShareOptions: React.FC<ManagePublicShareOptionsProps> = ({{...{ onRootClose, publicURL }}onUpdate={handlePublicURLUpdate}/>+ <ManageTemplate+ {...{+ collection,+ onRootClose,+ onRemotePull,+ setBlockingLoad,+ }}+ /><RowButtonGroup><ManageDeviceLimit{...{ onRootClose, publicURL }}@@ -1806,3 +1815,88 @@ const SetPublicLinkPassword: React.FC<SetPublicLinkPasswordProps> = ({</Dialog>);};++interface ManageTemplateProps {+ onRootClose: () => void;+ collection: Collection;+ onRemotePull: (opts?: RemotePullOpts) => Promise<void>;+ setBlockingLoad: (value: boolean) => void;+}++const ManageTemplate: React.FC<ManageTemplateProps> = ({+ onRootClose,+ collection,+ onRemotePull,+ setBlockingLoad,+}) => {+ const { show: showTemplateOptions, props: templateOptionsVisibilityProps } =+ useModalVisibility();++ const options = useMemo(() => templateOptions(), []);++ const currentTemplate =+ collection.pubMagicMetadata?.data?.template || "default";++ const changeTemplateValue = (value: string) => async () => {+ if (value === currentTemplate) return;++ setBlockingLoad(true);+ try {+ await updateCollectionTemplate(collection, value);+ await onRemotePull({ silent: true });+ templateOptionsVisibilityProps.onClose();+ } catch (e) {+ log.error("Could not update collection template", e);+ } finally {+ setBlockingLoad(false);+ }+ };++ return (+ <>+ <RowButtonGroup>+ <RowButton+ label={t("Template")}+ caption={+ currentTemplate === "trip" ? t("Trip") : t("Default")+ }+ onClick={showTemplateOptions}+ endIcon={<ChevronRightIcon />}+ />+ </RowButtonGroup>+ <TitledNestedSidebarDrawer+ anchor="right"+ {...templateOptionsVisibilityProps}+ onRootClose={onRootClose}+ title={t("Template")}+ >+ <Stack sx={{ gap: "32px", py: "20px", px: "8px" }}>+ <RowButtonGroup>+ {options.map(({ label, value }, index) => (+ <React.Fragment key={value}>+ <RowButton+ fontWeight="regular"+ onClick={changeTemplateValue(value)}+ label={label}+ endIcon={+ currentTemplate === value && (+ <DoneIcon />+ )+ }+ />+ {index != options.length - 1 && (+ <RowButtonDivider />+ )}+ </React.Fragment>+ ))}+ </RowButtonGroup>+ </Stack>+ </TitledNestedSidebarDrawer>+ </>+ );+};++const templateOptions = () => [+ { label: t("Default"), value: "default" },+ { label: t("Trip"), value: "trip" },+];diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsxindex 732a2ee0b6..8a86941648 100644--- a/web/apps/photos/src/pages/shared-albums.tsx+++ b/web/apps/photos/src/pages/shared-albums.tsx@@ -463,7 +463,8 @@ export default function PublicCollectionGallery() {);}- const isTripsTemplate = process.env.NEXT_PUBLIC_USE_TRIPS_VIEWER === "true";+ const isTripsTemplate =+ publicCollection?.pubMagicMetadata?.data.template === "trip";return (<FullScreenDropZonediff --git a/web/packages/media/collection.ts b/web/packages/media/collection.tsindex b8412a6d65..64d809eef2 100644--- a/web/packages/media/collection.ts+++ b/web/packages/media/collection.ts@@ -675,6 +675,14 @@ export interface CollectionPublicMagicMetadataData {* To reset to the default cover, set this to 0.*/coverID?: number;+ /**+ * The template type for the public collection view.+ *+ * Expected to be one of: "default", "trip".+ *+ * The default is "default".+ */+ template?: string;}/**@@ -683,6 +691,7 @@ export interface CollectionPublicMagicMetadataData {export const CollectionPublicMagicMetadataData = z.looseObject({asc: z.boolean().nullish().transform(nullToUndefined),coverID: z.number().nullish().transform(nullToUndefined),+ template: z.string().nullish().transform(nullToUndefined),});/**diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.tsindex f231c64f70..782dd99037 100644--- a/web/packages/new/photos/services/collection.ts+++ b/web/packages/new/photos/services/collection.ts@@ -1036,6 +1036,22 @@ export const updateCollectionSortOrder = async (asc: boolean,) => updateCollectionPublicMagicMetadata(collection, { asc });+/**+ * Change the template type of a collection on remote.+ *+ * Remote only, does not modify local state.+ *+ * This function works only for collections owned by the user.+ *+ * @param collection The collection whose template we want to change.+ *+ * @param template The template type ("default", "trip").+ */+export const updateCollectionTemplate = async (+ collection: Collection,+ template: string,+) => updateCollectionPublicMagicMetadata(collection, { template });+/*** Update the private magic metadata of a collection on remote.*