π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Conv
Manav Rathi44ea3d92e27c
diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsxindex 85266d965f..23cdc010c2 100644--- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx+++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx@@ -36,8 +36,6 @@ import {GalleryItemsSummary,} from "ente-new/photos/components/gallery/ListHeader";import {- ALL_SECTION,- HIDDEN_ITEMS_SECTION,isHiddenCollection,leaveSharedCollection,renameCollection,@@ -45,9 +43,10 @@ import {updateCollectionSortOrder,updateCollectionVisibility,} from "ente-new/photos/services/collection";-import type {- CollectionSummary,- CollectionSummaryType,+import {+ PseudoCollectionID,+ type CollectionSummary,+ type CollectionSummaryType,} from "ente-new/photos/services/collection-summary";import {clearLocalTrash,@@ -207,12 +206,12 @@ const CollectionOptions: React.FC<CollectionHeaderProps> = ({const deleteCollectionAlongWithFiles = wrap(async () => {await CollectionAPI.deleteCollection(activeCollection.id, false);- setActiveCollectionID(ALL_SECTION);+ setActiveCollectionID(PseudoCollectionID.all);});const deleteCollectionButKeepFiles = wrap(async () => {await CollectionAPI.deleteCollection(activeCollection.id, true);- setActiveCollectionID(ALL_SECTION);+ setActiveCollectionID(PseudoCollectionID.all);});const confirmEmptyTrash = () =>@@ -229,7 +228,7 @@ const CollectionOptions: React.FC<CollectionHeaderProps> = ({const doEmptyTrash = wrap(async () => {await emptyTrash();await clearLocalTrash();- setActiveCollectionID(ALL_SECTION);+ setActiveCollectionID(PseudoCollectionID.all);});const _downloadCollection = () => {@@ -275,7 +274,7 @@ const CollectionOptions: React.FC<CollectionHeaderProps> = ({const leaveSharedAlbum = wrap(async () => {await leaveSharedCollection(activeCollection.id);- setActiveCollectionID(ALL_SECTION);+ setActiveCollectionID(PseudoCollectionID.all);});const pinAlbum = wrap(() =>@@ -291,7 +290,7 @@ const CollectionOptions: React.FC<CollectionHeaderProps> = ({activeCollection,ItemVisibility.hidden,);- setActiveCollectionID(ALL_SECTION);+ setActiveCollectionID(PseudoCollectionID.all);});const unhideAlbum = wrap(async () => {@@ -299,7 +298,7 @@ const CollectionOptions: React.FC<CollectionHeaderProps> = ({activeCollection,ItemVisibility.visible,);- setActiveCollectionID(HIDDEN_ITEMS_SECTION);+ setActiveCollectionID(PseudoCollectionID.hiddenItems);});const changeSortOrderAsc = wrap(() =>diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsxindex ded05c4a61..4bc8c0ae57 100644--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx@@ -8,11 +8,11 @@ import {type GalleryBarImplProps,} from "ente-new/photos/components/gallery/BarImpl";import { PeopleHeader } from "ente-new/photos/components/gallery/PeopleHeader";-import { ALL_SECTION } from "ente-new/photos/services/collection";import {areOnlySystemCollections,collectionsSortBy,isSystemCollection,+ PseudoCollectionID,shouldShowOnCollectionBar,type CollectionsSortBy,type CollectionSummaries,@@ -108,7 +108,7 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({() =>shouldHide ||(areOnlySystemCollections(toShowCollectionSummaries) &&- activeCollectionID === ALL_SECTION),+ activeCollectionID === PseudoCollectionID.all),[shouldHide, toShowCollectionSummaries, activeCollectionID],);diff --git a/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx b/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsxindex d5a0f94151..6be0160d18 100644--- a/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx+++ b/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx@@ -17,7 +17,6 @@ import { useBaseContext } from "ente-base/context";import type { Collection } from "ente-media/collection";import type { CollectionSelectorAttributes } from "ente-new/photos/components/CollectionSelector";import type { GalleryBarMode } from "ente-new/photos/components/gallery/reducer";-import { ALL_SECTION } from "ente-new/photos/services/collection";import { PseudoCollectionID } from "ente-new/photos/services/collection-summary";import { t } from "i18next";import { type CollectionOp } from "utils/collection";@@ -338,14 +337,14 @@ const SelectedFileOptions = ({</IconButton></Tooltip>)}- {activeCollectionID === ALL_SECTION && (+ {activeCollectionID === PseudoCollectionID.all && (<Tooltip title={t("archive")}><IconButton onClick={handleFileOp("archive")}><ArchiveIcon /></IconButton></Tooltip>)}- {activeCollectionID !== ALL_SECTION &&+ {activeCollectionID !== PseudoCollectionID.all &&activeCollectionID != PseudoCollectionID.archiveItems &&!isFavoriteCollection && (<>diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex a0f71d7277..6576f1ff6a 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -71,8 +71,11 @@ import {import { useIsOffline } from "ente-new/photos/components/utils/use-is-offline";import { usePeopleStateSnapshot } from "ente-new/photos/components/utils/use-snapshot";import { shouldShowWhatsNew } from "ente-new/photos/services/changelog";-import { ALL_SECTION, createAlbum } from "ente-new/photos/services/collection";-import { areOnlySystemCollections } from "ente-new/photos/services/collection-summary";+import { createAlbum } from "ente-new/photos/services/collection";+import {+ areOnlySystemCollections,+ PseudoCollectionID,+} from "ente-new/photos/services/collection-summary";import { getAllLocalCollections } from "ente-new/photos/services/collections";import exportService from "ente-new/photos/services/export";import {@@ -183,7 +186,7 @@ const Page: React.FC = () => {ownCount: 0,count: 0,collectionID: 0,- context: { mode: "albums", collectionID: ALL_SECTION },+ context: { mode: "albums", collectionID: PseudoCollectionID.all },});const [blockingLoad, setBlockingLoad] = useState(false);const [shouldDisableDropzone, setShouldDisableDropzone] = useState(false);@@ -375,7 +378,7 @@ const Page: React.FC = () => {return;}let collectionURL = "";- if (activeCollectionID !== ALL_SECTION) {+ if (activeCollectionID !== PseudoCollectionID.all) {// TODO: Is this URL param even used?collectionURL = `?collection=${activeCollectionID}`;}@@ -1080,7 +1083,7 @@ const Page: React.FC = () => {!isFirstLoad &&!normalFiles?.length &&!hiddenFiles?.length &&- activeCollectionID === ALL_SECTION ? (+ activeCollectionID === PseudoCollectionID.all ? (<GalleryEmptyStateisUploadInProgress={uploadManager.isUploadInProgress()}onUpload={openUploader}diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsxindex 25e3d62684..b879e3eaf7 100644--- a/web/apps/photos/src/pages/shared-albums.tsx+++ b/web/apps/photos/src/pages/shared-albums.tsx@@ -54,10 +54,8 @@ import {GalleryItemsHeaderAdapter,GalleryItemsSummary,} from "ente-new/photos/components/gallery/ListHeader";-import {- ALL_SECTION,- isHiddenCollection,-} from "ente-new/photos/services/collection";+import { isHiddenCollection } from "ente-new/photos/services/collection";+import { PseudoCollectionID } from "ente-new/photos/services/collection-summary";import { sortFiles } from "ente-new/photos/services/files";import { usePhotosAppContext } from "ente-new/photos/types/context";import { CustomError, parseSharingErrorCodes } from "ente-shared/error";@@ -520,7 +518,7 @@ export default function PublicCollectionGallery() {selectable={downloadEnabled}selected={selected}setSelected={setSelected}- activeCollectionID={ALL_SECTION}+ activeCollectionID={PseudoCollectionID.all}setFilesDownloadProgressAttributesCreator={setFilesDownloadProgressAttributesCreator}diff --git a/web/apps/photos/src/utils/collection.ts b/web/apps/photos/src/utils/collection.tsindex 6f8ce1b21b..628cc9f095 100644--- a/web/apps/photos/src/utils/collection.ts+++ b/web/apps/photos/src/utils/collection.ts@@ -9,12 +9,12 @@ import {createAlbum,defaultHiddenCollectionUserFacingName,findDefaultHiddenCollectionIDs,- HIDDEN_ITEMS_SECTION,isHiddenCollection,isIncomingShare,moveToCollection,restoreToCollection,} from "ente-new/photos/services/collection";+import { PseudoCollectionID } from "ente-new/photos/services/collection-summary";import {getAllLocalCollections,getLocalCollections,@@ -113,7 +113,7 @@ export async function downloadDefaultHiddenCollectionHelper(const setFilesDownloadProgressAttributes =setFilesDownloadProgressAttributesCreator(defaultHiddenCollectionUserFacingName,- HIDDEN_ITEMS_SECTION,+ PseudoCollectionID.hiddenItems,true,);diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.tsindex 8e6c2b48b0..55134f232b 100644--- a/web/packages/new/photos/components/gallery/reducer.ts+++ b/web/packages/new/photos/components/gallery/reducer.ts@@ -16,9 +16,7 @@ import { includes } from "ente-utils/type-guards";import { t } from "i18next";import React, { useReducer } from "react";import {- ALL_SECTION,findDefaultHiddenCollectionIDs,- HIDDEN_ITEMS_SECTION,isDefaultHiddenCollection,isIncomingShare,} from "../../services/collection";@@ -534,7 +532,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = ();const view = {type: "albums" as const,- activeCollectionSummaryID: ALL_SECTION,+ activeCollectionSummaryID: PseudoCollectionID.all,activeCollection: undefined,};@@ -1011,7 +1009,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (pendingSearchSuggestions: [],view: {type: "albums",- activeCollectionSummaryID: ALL_SECTION,+ activeCollectionSummaryID: PseudoCollectionID.all,activeCollection: undefined,},isInSearchMode: false,@@ -1028,7 +1026,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (pendingSearchSuggestions: [],view: {type: "hidden-albums",- activeCollectionSummaryID: HIDDEN_ITEMS_SECTION,+ activeCollectionSummaryID: PseudoCollectionID.hiddenItems,activeCollection: undefined,},isInSearchMode: false,@@ -1073,7 +1071,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (? "hidden-albums": "albums",activeCollectionSummaryID:- action.collectionSummaryID ?? ALL_SECTION,+ action.collectionSummaryID ?? PseudoCollectionID.all,activeCollection: state.normalCollections.concat(state.hiddenCollections).find(({ id }) => id === action.collectionSummaryID),@@ -1292,9 +1290,9 @@ const deriveNormalCollectionSummaries = (normalFiles,archivedFileIDs,);- normalCollectionSummaries.set(ALL_SECTION, {+ normalCollectionSummaries.set(PseudoCollectionID.all, {...pseudoCollectionOptionsForFiles(allSectionFiles),- id: ALL_SECTION,+ id: PseudoCollectionID.all,type: "all",attributes: ["all"],name: t("section_all"),@@ -1347,9 +1345,9 @@ const deriveHiddenCollectionSummaries = (const defaultHiddenFiles = uniqueFilesByID(hiddenFiles.filter((file) => dhcIDs.has(file.collectionID)),);- hiddenCollectionSummaries.set(HIDDEN_ITEMS_SECTION, {+ hiddenCollectionSummaries.set(PseudoCollectionID.hiddenItems, {...pseudoCollectionOptionsForFiles(defaultHiddenFiles),- id: HIDDEN_ITEMS_SECTION,+ id: PseudoCollectionID.hiddenItems,name: t("hidden_items"),type: "hiddenItems",attributes: ["hiddenItems"],@@ -1579,7 +1577,8 @@ const deriveAlbumsViewAndSelectedID = (selectedCollectionSummaryID: activeCollectionSummaryID,view: {type: "albums" as const,- activeCollectionSummaryID: activeCollectionSummaryID ?? ALL_SECTION,+ activeCollectionSummaryID:+ activeCollectionSummaryID ?? PseudoCollectionID.all,activeCollection,},};@@ -1606,7 +1605,7 @@ const deriveHiddenAlbumsViewAndSelectedID = (view: {type: "hidden-albums" as const,activeCollectionSummaryID:- activeCollectionSummaryID ?? HIDDEN_ITEMS_SECTION,+ activeCollectionSummaryID ?? PseudoCollectionID.hiddenItems,activeCollection,},};@@ -1859,7 +1858,7 @@ const deriveAlbumsFilteredFiles = (return activeCollectionSummaryID === file.collectionID;}- if (activeCollectionSummaryID === ALL_SECTION) {+ if (activeCollectionSummaryID === PseudoCollectionID.all) {// Archived files (whether individually archived, or part of some// archived album) should not be shown in "All".if (archivedFileIDs.has(file.id)) {@@ -1890,9 +1889,9 @@ const deriveHiddenAlbumsFilteredFiles = (const filteredFiles = hiddenFiles.filter((file) => {if (tempDeletedFileIDs.has(file.id)) return false;- // "Hidden" shows all standalone hidden files.+ // "Hidden items" shows all individually hidden files.if (- activeCollectionSummaryID === HIDDEN_ITEMS_SECTION &&+ activeCollectionSummaryID == PseudoCollectionID.hiddenItems &&defaultHiddenCollectionIDs.has(file.collectionID)) {return true;diff --git a/web/packages/new/photos/services/collection-summary.ts b/web/packages/new/photos/services/collection-summary.tsindex 128657f72b..4c4c207e99 100644--- a/web/packages/new/photos/services/collection-summary.ts+++ b/web/packages/new/photos/services/collection-summary.ts@@ -72,9 +72,6 @@ export const PseudoCollectionID = {hiddenItems: -4,} as const;-export const HIDDEN_ITEMS_SECTION = -4;-export const ALL_SECTION = 0;-/*** A massaged version of a collection or a pseudo-collection suitable for being* directly shown in the UI.diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.tsindex 77bad86265..7dbca8aacf 100644--- a/web/packages/new/photos/services/collection.ts+++ b/web/packages/new/photos/services/collection.ts@@ -50,9 +50,6 @@ const defaultHiddenCollectionName = ".hidden";export const defaultHiddenCollectionUserFacingName = "Hidden";const favoritesCollectionName = "Favorites";-export const HIDDEN_ITEMS_SECTION = -4;-export const ALL_SECTION = 0;-/*** Return the "user facing" name of the given collection.*