Skip to content

armgit / ente

Public Imported from GitHub
0

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

Header

Manav Rathibc5be62de4eb
diff --git a/web/apps/photos/src/components/Collections/CollectionInfoWithOptions.tsx b/web/apps/photos/src/components/Collections/CollectionListHeader.tsx
similarity index 97%
rename from web/apps/photos/src/components/Collections/CollectionInfoWithOptions.tsx
rename to web/apps/photos/src/components/Collections/CollectionListHeader.tsx
index fe362a4d87..c1cd09a781 100644
--- a/web/apps/photos/src/components/Collections/CollectionInfoWithOptions.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionListHeader.tsx
@@ -1,3 +1,4 @@
+import { assertionFailed } from "@/base/assert";
import log from "@/base/log";
import type { Collection } from "@/media/collection";
import { ItemVisibility } from "@/media/file-metadata";
@@ -57,22 +58,23 @@ import {
} from "utils/collection";
import { isArchivedCollection, isPinnedCollection } from "utils/magicMetadata";
-interface Iprops {
- activeCollection: Collection;
+interface CollectionListHeaderProps {
collectionSummary: CollectionSummary;
+ activeCollection: Collection;
+ setActiveCollectionID: (collectionID: number) => void;
setCollectionNamerAttributes: SetCollectionNamerAttributes;
showCollectionShareModal: () => void;
setFilesDownloadProgressAttributesCreator: SetFilesDownloadProgressAttributesCreator;
isActiveCollectionDownloadInProgress: () => boolean;
- setActiveCollectionID: (collectionID: number) => void;
setShowAlbumCastDialog: Dispatch<SetStateAction<boolean>>;
}
-export default function CollectionInfoWithOptions({
+export const CollectionListHeader: React.FC<CollectionListHeaderProps> = ({
collectionSummary,
- ...props
-}: Iprops) {
+ ...rest
+}) => {
if (!collectionSummary) {
+ assertionFailed("CollectionListHeader without a collection");
return <></>;
}
@@ -105,29 +107,22 @@ export default function CollectionInfoWithOptions({
endIcon={<EndIcon type={type} />}
/>
{shouldShowOptions(type) && (
- <CollectionOptions
- {...props}
- collectionSummaryType={type}
- />
+ <CollectionOptions collectionSummaryType={type} {...rest} />
)}
</SpaceBetweenFlex>
</GalleryItemsHeaderAdapter>
);
-}
+};
const shouldShowOptions = (type: CollectionSummaryType) =>
type != "all" && type != "archive";
-interface CollectionOptionsProps {
- setCollectionNamerAttributes: SetCollectionNamerAttributes;
- setFilesDownloadProgressAttributesCreator: SetFilesDownloadProgressAttributesCreator;
- isActiveCollectionDownloadInProgress: () => boolean;
- activeCollection: Collection;
+type CollectionOptionsProps = Omit<
+ CollectionListHeaderProps,
+ "collectionSummary"
+> & {
collectionSummaryType: CollectionSummaryType;
- showCollectionShareModal: () => void;
- setActiveCollectionID: (collectionID: number) => void;
- setShowAlbumCastDialog: Dispatch<SetStateAction<boolean>>;
-}
+};
const CollectionOptions: React.FC<CollectionOptionsProps> = ({
activeCollection,
diff --git a/web/apps/photos/src/components/Collections/index.tsx b/web/apps/photos/src/components/Collections/index.tsx
index 203bff37b4..223bb20756 100644
--- a/web/apps/photos/src/components/Collections/index.tsx
+++ b/web/apps/photos/src/components/Collections/index.tsx
@@ -15,7 +15,7 @@ import {
removeData,
} from "@ente/shared/storage/localStorage";
import AllCollections from "components/Collections/AllCollections";
-import CollectionInfoWithOptions from "components/Collections/CollectionInfoWithOptions";
+import { CollectionListHeader } from "components/Collections/CollectionListHeader";
import { SetCollectionNamerAttributes } from "components/Collections/CollectionNamer";
import CollectionShare from "components/Collections/CollectionShare";
import { ITEM_TYPE, TimeStampListItem } from "components/PhotoList";
@@ -126,22 +126,20 @@ export const Collections: React.FC<CollectionsProps> = ({
setPhotoListHeader({
item: (
- <CollectionInfoWithOptions
+ <CollectionListHeader
collectionSummary={toShowCollectionSummaries.get(
activeCollectionID,
)}
- activeCollection={activeCollection}
- setCollectionNamerAttributes={setCollectionNamerAttributes}
+ {...{
+ activeCollection,
+ setActiveCollectionID,
+ setCollectionNamerAttributes,
+ setFilesDownloadProgressAttributesCreator,
+ isActiveCollectionDownloadInProgress,
+ }}
showCollectionShareModal={() =>
setOpenCollectionShareView(true)
}
- setFilesDownloadProgressAttributesCreator={
- setFilesDownloadProgressAttributesCreator
- }
- isActiveCollectionDownloadInProgress={
- isActiveCollectionDownloadInProgress
- }
- setActiveCollectionID={setActiveCollectionID}
setShowAlbumCastDialog={setOpenAlbumCastDialog}
/>
),