Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Ditto

Manav Rathi1eaaafb8df31
diff --git a/web/apps/photos/src/components/Export.tsx b/web/apps/photos/src/components/Export.tsx
index a3feaae4af..b245a33d1e 100644
--- a/web/apps/photos/src/components/Export.tsx
+++ b/web/apps/photos/src/components/Export.tsx
@@ -42,13 +42,13 @@ import ExportInProgress from "./ExportInProgress";
import ExportInit from "./ExportInit";
type ExportProps = ModalVisibilityProps & {
- collectionNameMap: Map<number, string>;
+ allCollectionsNameByID: Map<number, string>;
};
export const Export: React.FC<ExportProps> = ({
open,
onClose,
- collectionNameMap,
+ allCollectionsNameByID,
}) => {
const { showMiniDialog } = useBaseContext();
const [exportStage, setExportStage] = useState(ExportStage.INIT);
@@ -202,7 +202,7 @@ export const Export: React.FC<ExportProps> = ({
lastExportTime={lastExportTime}
exportProgress={exportProgress}
pendingExports={pendingExports}
- collectionNameMap={collectionNameMap}
+ allCollectionsNameByID={allCollectionsNameByID}
/>
</Dialog>
);
@@ -291,7 +291,7 @@ const ExportDynamicContent = ({
lastExportTime,
exportProgress,
pendingExports,
- collectionNameMap,
+ allCollectionsNameByID,
}: {
exportStage: ExportStage;
startExport: (opts?: ExportOpts) => void;
@@ -300,7 +300,7 @@ const ExportDynamicContent = ({
lastExportTime: number;
exportProgress: ExportProgress;
pendingExports: EnteFile[];
- collectionNameMap: Map<number, string>;
+ allCollectionsNameByID: Map<number, string>;
}) => {
switch (exportStage) {
case ExportStage.INIT:
@@ -326,7 +326,7 @@ const ExportDynamicContent = ({
onHide={onHide}
lastExportTime={lastExportTime}
pendingExports={pendingExports}
- collectionNameMap={collectionNameMap}
+ allCollectionsNameByID={allCollectionsNameByID}
onResync={() => startExport({ resync: true })}
/>
);
diff --git a/web/apps/photos/src/components/ExportFinished.tsx b/web/apps/photos/src/components/ExportFinished.tsx
index 3f13a8c2a5..9b1507c6a8 100644
--- a/web/apps/photos/src/components/ExportFinished.tsx
+++ b/web/apps/photos/src/components/ExportFinished.tsx
@@ -11,7 +11,7 @@ import ExportPendingList from "./ExportPendingList";
interface Props {
pendingExports: EnteFile[];
- collectionNameMap: Map<number, string>;
+ allCollectionsNameByID: Map<number, string>;
onHide: () => void;
lastExportTime: number;
/** Called when the user presses the "Resync" button. */
@@ -73,7 +73,7 @@ export default function ExportFinished(props: Props) {
</DialogActions>
<ExportPendingList
pendingExports={props.pendingExports}
- collectionNameMap={props.collectionNameMap}
+ allCollectionsNameByID={props.allCollectionsNameByID}
isOpen={pendingFileListView}
onClose={closePendingFileList}
/>
diff --git a/web/apps/photos/src/components/ExportPendingList.tsx b/web/apps/photos/src/components/ExportPendingList.tsx
index c9e87afca8..4433330665 100644
--- a/web/apps/photos/src/components/ExportPendingList.tsx
+++ b/web/apps/photos/src/components/ExportPendingList.tsx
@@ -10,7 +10,7 @@ import { t } from "i18next";
interface Iprops {
isOpen: boolean;
onClose: () => void;
- collectionNameMap: Map<number, string>;
+ allCollectionsNameByID: Map<number, string>;
pendingExports: EnteFile[];
}
@@ -36,7 +36,7 @@ const ExportPendingList = (props: Iprops) => {
/>
</Box>
<ItemContainer>
- {`${props.collectionNameMap.get(file.collectionID)} / ${
+ {`${props.allCollectionsNameByID.get(file.collectionID)} / ${
file.metadata.title
}`}
</ItemContainer>
@@ -45,7 +45,7 @@ const ExportPendingList = (props: Iprops) => {
};
const getItemTitle = (file: EnteFile) => {
- return `${props.collectionNameMap.get(file.collectionID)} / ${
+ return `${props.allCollectionsNameByID.get(file.collectionID)} / ${
file.metadata.title
}`;
};
diff --git a/web/apps/photos/src/components/PhotoFrame.tsx b/web/apps/photos/src/components/PhotoFrame.tsx
index 7cd68255ab..8b914da1a9 100644
--- a/web/apps/photos/src/components/PhotoFrame.tsx
+++ b/web/apps/photos/src/components/PhotoFrame.tsx
@@ -112,8 +112,8 @@ export interface PhotoFrameProps {
/** This will be set if mode is "people". */
activePersonID?: string | undefined;
enableDownload?: boolean;
- fileToCollectionsMap?: Map<number, number[]>;
- collectionNameMap?: Map<number, string>;
+ fileCollectionIDs?: Map<number, number[]>;
+ allCollectionsNameByID?: Map<number, string>;
showAppDownloadBanner?: boolean;
setIsPhotoSwipeOpen?: (value: boolean) => void;
isInHiddenSection?: boolean;
@@ -138,8 +138,8 @@ const PhotoFrame = ({
activeCollectionID,
activePersonID,
enableDownload,
- fileToCollectionsMap,
- collectionNameMap,
+ fileCollectionIDs,
+ allCollectionsNameByID,
showAppDownloadBanner,
setIsPhotoSwipeOpen,
isInHiddenSection,
@@ -555,8 +555,8 @@ const PhotoFrame = ({
favoriteFileIDs,
markUnsyncedFavoriteUpdate,
markTempDeleted,
- collectionNameMap,
- fileToCollectionsMap,
+ allCollectionsNameByID,
+ fileCollectionIDs,
setFilesDownloadProgressAttributesCreator,
onSelectPerson,
}}
diff --git a/web/apps/photos/src/components/PhotoViewer/index.tsx b/web/apps/photos/src/components/PhotoViewer/index.tsx
index 25744354a3..4f7bc0d348 100644
--- a/web/apps/photos/src/components/PhotoViewer/index.tsx
+++ b/web/apps/photos/src/components/PhotoViewer/index.tsx
@@ -102,8 +102,8 @@ export type PhotoViewerProps = Pick<
isInHiddenSection: boolean;
enableDownload: boolean;
setFilesDownloadProgressAttributesCreator: SetFilesDownloadProgressAttributesCreator;
- fileToCollectionsMap?: Map<number, number[]>;
- collectionNameMap?: Map<number, string>;
+ fileCollectionIDs?: Map<number, number[]>;
+ allCollectionsNameByID?: Map<number, string>;
onSelectPerson?: FileInfoProps["onSelectPerson"];
};
@@ -136,8 +136,8 @@ export const PhotoViewer: React.FC<PhotoViewerProps> = ({
isInHiddenSection,
enableDownload,
setFilesDownloadProgressAttributesCreator,
- fileToCollectionsMap,
- collectionNameMap,
+ fileCollectionIDs,
+ allCollectionsNameByID,
onSelectPerson,
}) => {
const { showLoadingBar, hideLoadingBar } = usePhotosAppContext();
@@ -998,8 +998,8 @@ export const PhotoViewer: React.FC<PhotoViewerProps> = ({
showCollections={
!isTrashCollection && isOwnFile && !isInHiddenSection
}
- fileToCollectionsMap={fileToCollectionsMap}
- collectionNameMap={collectionNameMap}
+ fileCollectionIDs={fileCollectionIDs}
+ allCollectionsNameByID={allCollectionsNameByID}
scheduleUpdate={scheduleUpdate}
refreshPhotoswipe={refreshPhotoswipe}
onSelectCollection={handleSelectCollection}
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index afe799e483..2a1f26368f 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -1102,8 +1102,8 @@ const Page: React.FC = () => {
activeCollectionID={activeCollectionID}
activePersonID={activePerson?.id}
enableDownload={true}
- fileToCollectionsMap={state.fileCollectionIDs}
- collectionNameMap={state.allCollectionsNameByID}
+ fileCollectionIDs={state.fileCollectionIDs}
+ allCollectionsNameByID={state.allCollectionsNameByID}
showAppDownloadBanner={
files.length < 30 && !isInSearchMode
}
@@ -1119,7 +1119,7 @@ const Page: React.FC = () => {
)}
<Export
{...exportVisibilityProps}
- collectionNameMap={state.allCollectionsNameByID}
+ allCollectionsNameByID={state.allCollectionsNameByID}
/>
<AuthenticateUserModal
open={authenticateUserModalView}
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsx
index 856c230a59..6f4b666c6f 100644
--- a/web/apps/photos/src/pages/shared-albums.tsx
+++ b/web/apps/photos/src/pages/shared-albums.tsx
@@ -548,8 +548,8 @@ export default function PublicCollectionGallery() {
selected={selected}
activeCollectionID={ALL_SECTION}
enableDownload={downloadEnabled}
- fileToCollectionsMap={undefined}
- collectionNameMap={undefined}
+ fileCollectionIDs={undefined}
+ allCollectionsNameByID={undefined}
setFilesDownloadProgressAttributesCreator={
setFilesDownloadProgressAttributesCreator
}
diff --git a/web/apps/photos/src/utils/collection.ts b/web/apps/photos/src/utils/collection.ts
index aa46ab4a88..2cf35df026 100644
--- a/web/apps/photos/src/utils/collection.ts
+++ b/web/apps/photos/src/utils/collection.ts
@@ -348,14 +348,6 @@ export function isValidReplacementAlbum(
);
}
-export function getCollectionNameMap(
- collections: Collection[],
-): Map<number, string> {
- return new Map<number, string>(
- collections.map((collection) => [collection.id, collection.name]),
- );
-}
-
export const getOrCreateAlbum = async (
albumName: string,
existingCollections: Collection[],
diff --git a/web/packages/gallery/components/FileInfo.tsx b/web/packages/gallery/components/FileInfo.tsx
index 4b197d69d2..cbfcce934a 100644
--- a/web/packages/gallery/components/FileInfo.tsx
+++ b/web/packages/gallery/components/FileInfo.tsx
@@ -128,9 +128,8 @@ export type FileInfoProps = ModalVisibilityProps & {
* If set, then a clickable chip will be shown for each collection that this
* file is a part of.
*
- * Uses (and requires) {@link fileToCollectionsMap} and
- * {@link collectionNameMap}, so both of those props should also be set for
- * this to have an effect.
+ * Uses {@link fileCollectionIDs} and {@link allCollectionsNameByID}, so
+ * both of those props should also be set for this to have an effect.
*/
showCollections?: boolean;
/**
@@ -138,13 +137,13 @@ export type FileInfoProps = ModalVisibilityProps & {
*
* Used when {@link showCollections} is set.
*/
- fileToCollectionsMap?: Map<number, number[]>;
+ fileCollectionIDs?: Map<number, number[]>;
/**
* A map from collection IDs to their name.
*
* Used when {@link showCollections} is set.
*/
- collectionNameMap?: Map<number, string>;
+ allCollectionsNameByID?: Map<number, string>;
scheduleUpdate: () => void;
refreshPhotoswipe: () => void;
/**
@@ -166,8 +165,8 @@ export const FileInfo: React.FC<FileInfoProps> = ({
allowEdits,
allowMap,
showCollections,
- fileToCollectionsMap,
- collectionNameMap,
+ fileCollectionIDs,
+ allCollectionsNameByID,
scheduleUpdate,
refreshPhotoswipe,
onSelectCollection,
@@ -238,7 +237,6 @@ export const FileInfo: React.FC<FileInfoProps> = ({
refreshPhotoswipe,
}}
/>
-
<CreationTime {...{ file, allowEdits, scheduleUpdate }} />
<FileName {...{ file, exifInfo, allowEdits, scheduleUpdate }} />
@@ -319,35 +317,41 @@ export const FileInfo: React.FC<FileInfoProps> = ({
/>
</InfoItem>
)}
- {showCollections && collectionNameMap && (
- <InfoItem icon={<FolderOutlinedIcon />}>
- <Stack
- direction="row"
- sx={{
- gap: 1,
- flexWrap: "wrap",
- justifyContent: "flex-start",
- alignItems: "flex-start",
- }}
- >
- {fileToCollectionsMap
- ?.get(file.id)
- ?.filter((collectionID) =>
- collectionNameMap.has(collectionID),
- )
- ?.map((collectionID) => (
- <ChipButton
- key={collectionID}
- onClick={() =>
- onSelectCollection(collectionID)
- }
- >
- {collectionNameMap.get(collectionID)}
- </ChipButton>
- ))}
- </Stack>
- </InfoItem>
- )}
+ {showCollections &&
+ fileCollectionIDs &&
+ allCollectionsNameByID && (
+ <InfoItem icon={<FolderOutlinedIcon />}>
+ <Stack
+ direction="row"
+ sx={{
+ gap: 1,
+ flexWrap: "wrap",
+ justifyContent: "flex-start",
+ alignItems: "flex-start",
+ }}
+ >
+ {fileCollectionIDs
+ .get(file.id)
+ ?.filter((collectionID) =>
+ allCollectionsNameByID.has(
+ collectionID,
+ ),
+ )
+ ?.map((collectionID) => (
+ <ChipButton
+ key={collectionID}
+ onClick={() =>
+ onSelectCollection(collectionID)
+ }
+ >
+ {allCollectionsNameByID.get(
+ collectionID,
+ )}
+ </ChipButton>
+ ))}
+ </Stack>
+ </InfoItem>
+ )}
</Stack>
<RawExif
{...rawExifVisibilityProps}
diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.ts
index 174297859e..adc044d672 100644
--- a/web/packages/new/photos/components/gallery/reducer.ts
+++ b/web/packages/new/photos/components/gallery/reducer.ts
@@ -195,14 +195,13 @@ export interface GalleryState {
*/
favoriteFileIDs: Set<number>;
/**
- * User visible collection names indexed by collection IDs for fast lookup.
+ * A map from collection IDs to their user visible name.
*
- * This map will contain entries for all (both normal and hidden)
- * collections.
+ * It will contain entries for all collections (both normal and hidden).
*/
allCollectionsNameByID: Map<number, string>;
/**
- * A list of collection IDs to which a file belongs, indexed by file ID.
+ * A map from file IDs to the IDs of the collections that they're a part of.
*/
fileCollectionIDs: Map<number, number[]>;