Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix default hidden collection download

Manav Rathi4ed620db2892
diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
index 7b503e0d9a..0b2bc87a06 100644
--- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
@@ -74,10 +74,8 @@ interface CollectionHeaderProps {
* A header shown at the top of the list of photos in the gallery, when the
* gallery is showing a collection.
*/
-export const CollectionHeader: React.FC<CollectionHeaderProps> = ({
- collectionSummary,
- ...rest
-}) => {
+export const CollectionHeader: React.FC<CollectionHeaderProps> = (props) => {
+ const { collectionSummary } = props;
if (!collectionSummary) {
assertionFailed("Gallery/CollectionHeader without a collection");
return <></>;
@@ -111,9 +109,7 @@ export const CollectionHeader: React.FC<CollectionHeaderProps> = ({
fileCount={fileCount}
endIcon={<EndIcon type={type} />}
/>
- {shouldShowOptions(type) && (
- <CollectionOptions collectionSummaryType={type} {...rest} />
- )}
+ {shouldShowOptions(type) && <CollectionOptions {...props} />}
</SpaceBetweenFlex>
</GalleryItemsHeaderAdapter>
);
@@ -122,16 +118,9 @@ export const CollectionHeader: React.FC<CollectionHeaderProps> = ({
const shouldShowOptions = (type: CollectionSummaryType) =>
type != "all" && type != "archive";
-type CollectionOptionsProps = Omit<
- CollectionHeaderProps,
- "collectionSummary"
-> & {
- collectionSummaryType: CollectionSummaryType;
-};
-
-const CollectionOptions: React.FC<CollectionOptionsProps> = ({
+const CollectionOptions: React.FC<CollectionHeaderProps> = ({
activeCollection,
- collectionSummaryType,
+ collectionSummary,
setActiveCollectionID,
onCollectionShare,
onCollectionCast,
@@ -147,6 +136,8 @@ const CollectionOptions: React.FC<CollectionOptionsProps> = ({
const { show: showSortOrderMenu, props: sortOrderMenuVisibilityProps } =
useModalVisibility();
+ const { type: collectionSummaryType } = collectionSummary;
+
/**
* Return a new function by wrapping an async function in an error handler,
* showing the global loading bar when the function runs, and syncing with
@@ -248,11 +239,7 @@ const CollectionOptions: React.FC<CollectionOptionsProps> = ({
if (collectionSummaryType == "hiddenItems") {
return downloadDefaultHiddenCollectionHelper(
- setFilesDownloadProgressAttributesCreator(
- activeCollection.name,
- HIDDEN_ITEMS_SECTION,
- true,
- ),
+ setFilesDownloadProgressAttributesCreator,
);
} else {
return downloadCollectionHelper(
diff --git a/web/apps/photos/src/utils/collection.ts b/web/apps/photos/src/utils/collection.ts
index a531e08c51..d20908a8db 100644
--- a/web/apps/photos/src/utils/collection.ts
+++ b/web/apps/photos/src/utils/collection.ts
@@ -13,6 +13,7 @@ import { EnteFile } from "@/media/file";
import { ItemVisibility } from "@/media/file-metadata";
import {
DEFAULT_HIDDEN_COLLECTION_USER_FACING_NAME,
+ HIDDEN_ITEMS_SECTION,
addToCollection,
findDefaultHiddenCollectionIDs,
isHiddenCollection,
@@ -38,7 +39,10 @@ import {
updatePublicCollectionMagicMetadata,
updateSharedCollectionMagicMetadata,
} from "services/collectionService";
-import { SetFilesDownloadProgressAttributes } from "types/gallery";
+import {
+ SetFilesDownloadProgressAttributes,
+ type SetFilesDownloadProgressAttributesCreator,
+} from "types/gallery";
import { downloadFilesWithProgress } from "utils/file";
export enum COLLECTION_OPS_TYPE {
@@ -113,7 +117,7 @@ export async function downloadCollectionHelper(
}
export async function downloadDefaultHiddenCollectionHelper(
- setFilesDownloadProgressAttributes: SetFilesDownloadProgressAttributes,
+ setFilesDownloadProgressAttributesCreator: SetFilesDownloadProgressAttributesCreator,
) {
try {
const hiddenCollections = await getLocalCollections("hidden");
@@ -123,6 +127,13 @@ export async function downloadDefaultHiddenCollectionHelper(
const defaultHiddenCollectionFiles = hiddenFiles.filter((file) =>
defaultHiddenCollectionsIds.has(file.collectionID),
);
+ const setFilesDownloadProgressAttributes =
+ setFilesDownloadProgressAttributesCreator(
+ DEFAULT_HIDDEN_COLLECTION_USER_FACING_NAME,
+ HIDDEN_ITEMS_SECTION,
+ true,
+ );
+
await downloadCollectionFiles(
DEFAULT_HIDDEN_COLLECTION_USER_FACING_NAME,
defaultHiddenCollectionFiles,