π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move to gallery
Manav Rathiec5b5ca80d3d
diff --git a/web/apps/photos/src/components/DownloadStatusNotifications.tsx b/web/apps/photos/src/components/DownloadStatusNotifications.tsxindex 9872a858a3..95be991e99 100644--- a/web/apps/photos/src/components/DownloadStatusNotifications.tsx+++ b/web/apps/photos/src/components/DownloadStatusNotifications.tsx@@ -23,24 +23,18 @@ interface DownloadStatusNotificationsProps {*/onRemoveSaveGroup: (saveGroup: SaveGroup) => void;/**- * Called when the hidden section should be shown.- *- * This triggers the display of the dialog to authenticate the user, and the- * returned promise when (and only if) the user successfully reauthenticates.- *- * Since the hidden section is only relevant in the context of the photos- * app where there is a logged in user, this callback can be omitted in the- * context of the public albums app.- */- onShowHiddenSection?: () => Promise<void>;- /**- * Called when the collection with the given {@link collectionID} should be- * shown.+ * Called when the collection summary with the given {@link collectionID}+ * and "hidden" {@link attribute} should be shown.** This is only relevant in the context of the photos app, and can be- * omitted by the public albums app.+ * omitted by the public albums app. See the documentation of+ * {@link SaveGroup}'s {@link collectionSummaryID} property for why we don't+ * store the collection summary itself.*/- onShowCollection?: (collectionID: number) => void;+ onShowCollectionSummary?: (+ collectionSummaryID: number | undefined,+ isHiddenCollectionSummary: boolean | undefined,+ ) => void;}/**@@ -49,12 +43,7 @@ interface DownloadStatusNotificationsProps {*/export const DownloadStatusNotifications: React.FC<DownloadStatusNotificationsProps-> = ({- saveGroups,- onRemoveSaveGroup,- onShowHiddenSection,- onShowCollection,-}) => {+> = ({ saveGroups, onRemoveSaveGroup, onShowCollectionSummary }) => {const { showMiniDialog } = useBaseContext();const confirmCancelDownload = (group: SaveGroup) =>@@ -84,14 +73,11 @@ export const DownloadStatusNotifications: React.FC<const electron = globalThis.electron;if (electron) {electron.openDirectory(group.downloadDirPath);- } else if (onShowCollection) {- if (group.isHiddenCollectionSummary) {- void onShowHiddenSection().then(() => {- onShowCollection(group.collectionSummaryID);- });- } else {- onShowCollection(group.collectionSummaryID);- }+ } else if (onShowCollectionSummary) {+ onShowCollectionSummary(+ group.collectionSummaryID,+ group.isHiddenCollectionSummary,+ );} else {return undefined;}diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 51bd8a3324..08a75f4a67 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -89,6 +89,7 @@ import {import {haveOnlySystemCollections,PseudoCollectionID,+ type CollectionSummary,} from "ente-new/photos/services/collection-summary";import exportService from "ente-new/photos/services/export";import { updateFilesVisibility } from "ente-new/photos/services/file";@@ -789,7 +790,7 @@ const Page: React.FC = () => {setUploadTypeSelectorIntent(intent ?? "upload");};- const handleShowCollectionSummary = (+ const handleShowCollectionSummaryWithID = (collectionSummaryID: number | undefined,) => {// Trigger a pull of the latest data from remote when opening the trash.@@ -813,9 +814,45 @@ const Page: React.FC = () => {dispatch({ type: "showCollectionSummary", collectionSummaryID });};- // The same function can also be used to show collections since the- // namespace for the collection IDs and collection summary IDs are disjoint.- const handleShowCollection = handleShowCollectionSummary;+ /**+ * Switch to gallery view to show the {@link CollectionSummary}.+ *+ * @param cs The {@link CollectionSummary} to show.+ * If a {@link CollectionSummary} is not provided, show the "All" section.+ *+ * If the given {@link CollectionSummary} is hidden, first perform any+ * reauthentication as would be needed for showing the hidden section in the+ * app, and then shows the {@link CollectionSummary}.+ */+ // TODO(RE):+ // eslint-disable-next-line @typescript-eslint/no-unused-vars+ const handleShowCollectionSummary = (cs: CollectionSummary | undefined) => {+ if (cs?.attributes.has("hidden")) {+ void handleShowHiddenSection().then(() => {+ handleShowCollectionSummaryWithID(cs.id);+ });+ } else {+ handleShowCollectionSummaryWithID(cs.id);+ }+ };++ /**+ * A variant / reimplementation of {@link handleShowCollectionSummary} for+ * use by the {@link DownloadStatusNotifications} component (which does not+ * know about the {@link CollectionSummary} TypeScript type).+ */+ const handleDownloadStatusNotificationsShowCollectionSummary = (+ collectionSummaryID: number | undefined,+ isHiddenCollectionSummary: boolean | undefined,+ ) => {+ if (isHiddenCollectionSummary) {+ void handleShowHiddenSection().then(() => {+ handleShowCollectionSummaryWithID(collectionSummaryID);+ });+ } else {+ handleShowCollectionSummaryWithID(collectionSummaryID);+ }+ };const handleChangeBarMode = (mode: GalleryBarMode) =>mode == "people"@@ -955,8 +992,9 @@ const Page: React.FC = () => {/><DownloadStatusNotifications{...{ saveGroups, onRemoveSaveGroup }}- onShowHiddenSection={handleShowHiddenSection}- onShowCollection={handleShowCollection}+ onShowCollectionSummary={+ handleDownloadStatusNotificationsShowCollectionSummary+ }/><FixCreationTime{...fixCreationTimeVisibilityProps}@@ -1039,7 +1077,7 @@ const Page: React.FC = () => {}onChangeMode={handleChangeBarMode}setBlockingLoad={setBlockingLoad}- setActiveCollectionID={handleShowCollectionSummary}+ setActiveCollectionID={handleShowCollectionSummaryWithID}onRemotePull={remotePull}onSelectPerson={handleSelectPerson}/>@@ -1076,7 +1114,7 @@ const Page: React.FC = () => {state.uncategorizedCollectionSummaryID}onShowPlanSelector={showPlanSelector}- onShowCollectionSummary={handleShowCollectionSummary}+ onShowCollectionSummary={handleShowCollectionSummaryWithID}onShowHiddenSection={handleShowHiddenSection}onShowExport={showExport}onAuthenticateUser={authenticateUser}diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsxindex 7d1e52b8a3..9b2fe11689 100644--- a/web/apps/photos/src/pages/shared-albums.tsx+++ b/web/apps/photos/src/pages/shared-albums.tsx@@ -80,7 +80,6 @@ import {GalleryItemsHeaderAdapter,GalleryItemsSummary,} from "ente-new/photos/components/gallery/ListHeader";-import { isHiddenCollection } from "ente-new/photos/services/collection";import { PseudoCollectionID } from "ente-new/photos/services/collection-summary";import { usePhotosAppContext } from "ente-new/photos/types/context";import { t } from "i18next";@@ -649,7 +648,7 @@ const ListHeader: React.FC<ListHeaderProps> = ({publicCollection.name,publicCollection.id,publicFiles,- isHiddenCollection(publicCollection),+ undefined,onAddSaveGroup,);diff --git a/web/packages/gallery/components/utils/save-groups.ts b/web/packages/gallery/components/utils/save-groups.tsindex f37fd40b69..cb9c15dde9 100644--- a/web/packages/gallery/components/utils/save-groups.ts+++ b/web/packages/gallery/components/utils/save-groups.ts@@ -30,6 +30,12 @@ export interface SaveGroup {/*** If this save group is associated with a {@link CollectionSummary}, then* the ID of that collection summary.+ *+ * The {@link SaveGroup} type is also used in the context of the albums app,+ * which does not use or need the concept of link {@link CollectionSummary},+ * we to avoid taking a dependency of the type we store these two relevant+ * properties - {@link collectionSummaryID} and+ * {@link isHiddenCollectionSummary} - inline.*/collectionSummaryID?: number;/**diff --git a/web/packages/gallery/services/save.ts b/web/packages/gallery/services/save.tsindex 1eb1701087..73faa7e3d2 100644--- a/web/packages/gallery/services/save.ts+++ b/web/packages/gallery/services/save.ts@@ -52,12 +52,16 @@ export const downloadAndSaveFiles = (* When running in the context of the desktop app, instead of saving the files* in the directory selected by the user, files are saved in a directory with* the same name as the collection.+ *+ * @param isHiddenCollectionSummary `true` if the collection is associated with+ * a "hidden" collection or pseudo-collection in the app. Only relevant when+ * running in the context of the photos app, can be `undefined` otherwise.*/export const downloadAndSaveCollectionFiles = async (collectionSummaryName: string,collectionSummaryID: number,files: EnteFile[],- isHiddenCollectionSummary: boolean,+ isHiddenCollectionSummary: boolean | undefined,onAddSaveGroup: AddSaveGroup,) =>downloadAndSave(diff --git a/web/packages/new/photos/services/collection-summary.ts b/web/packages/new/photos/services/collection-summary.tsindex a735dc8114..2876e305e1 100644--- a/web/packages/new/photos/services/collection-summary.ts+++ b/web/packages/new/photos/services/collection-summary.ts@@ -19,8 +19,8 @@ export type CollectionSummaryAttribute =| "sharedIncomingCollaborator"| "sharedOnlyViaLink"| "system"- | "hideFromCollectionBar"| "archived"+ | "hideFromCollectionBar"| "pinned";/**