Skip to content

armgit / ente

Public Imported from GitHub
0

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

Conv to set

Manav Rathic5ec0891c969
diff --git a/web/packages/new/photos/components/gallery/BarImpl.tsx b/web/packages/new/photos/components/gallery/BarImpl.tsx
index bd3d94fb1e..49e801d7ca 100644
--- a/web/packages/new/photos/components/gallery/BarImpl.tsx
+++ b/web/packages/new/photos/components/gallery/BarImpl.tsx
@@ -528,7 +528,7 @@ const CardText: React.FC<React.PropsWithChildren> = ({ children }) => (
);
interface CollectionBarCardIconProps {
- attributes: CollectionSummaryType[];
+ attributes: Set<CollectionSummaryType>;
}
const CollectionBarCardIcon: React.FC<CollectionBarCardIconProps> = ({
@@ -538,18 +538,16 @@ const CollectionBarCardIcon: React.FC<CollectionBarCardIconProps> = ({
// will be true simultaneously even in the rarest of cases (a pinned and
// shared album that is also archived), and there is enough space for 3.
<CollectionBarCardIcon_>
- {attributes.includes("favorites") && <FavoriteRoundedIcon />}
- {attributes.includes("pinned") && (
+ {attributes.has("favorites") && <FavoriteRoundedIcon />}
+ {attributes.has("pinned") && (
// Need && to override the 20px set in the container.
<PushPinIcon sx={{ "&&": { fontSize: "18px" } }} />
)}
- {(attributes.includes("outgoingShare") ||
- attributes.includes("incomingShareViewer") ||
- attributes.includes("incomingShareCollaborator")) && <PeopleIcon />}
- {attributes.includes("sharedOnlyViaLink") && <LinkIcon />}
- {attributes.includes("archived") && (
- <ArchiveIcon sx={{ opacity: 0.48 }} />
- )}
+ {(attributes.has("outgoingShare") ||
+ attributes.has("incomingShareViewer") ||
+ attributes.has("incomingShareCollaborator")) && <PeopleIcon />}
+ {attributes.has("sharedOnlyViaLink") && <LinkIcon />}
+ {attributes.has("archived") && <ArchiveIcon sx={{ opacity: 0.48 }} />}
</CollectionBarCardIcon_>
);
diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.ts
index aa75cba123..5e9fafac81 100644
--- a/web/packages/new/photos/components/gallery/reducer.ts
+++ b/web/packages/new/photos/components/gallery/reducer.ts
@@ -1254,7 +1254,7 @@ const deriveNormalCollectionSummaries = (
...pseudoCollectionOptionsForFiles([]),
id,
type: "uncategorized",
- attributes: ["uncategorized"],
+ attributes: new Set(["uncategorized"]),
name: t("section_uncategorized"),
});
}
@@ -1275,7 +1275,7 @@ const deriveNormalCollectionSummaries = (
...pseudoCollectionOptionsForFiles(allSectionFiles),
id: PseudoCollectionID.all,
type: "all",
- attributes: ["all"],
+ attributes: new Set(["all"]),
name: t("section_all"),
});
@@ -1287,7 +1287,7 @@ const deriveNormalCollectionSummaries = (
id: PseudoCollectionID.trash,
name: t("section_trash"),
type: "trash",
- attributes: ["trash"],
+ attributes: new Set(["trash"]),
coverFile: undefined,
});
@@ -1296,7 +1296,7 @@ const deriveNormalCollectionSummaries = (
id: PseudoCollectionID.archiveItems,
name: t("section_archive"),
type: "archive",
- attributes: ["archive"],
+ attributes: new Set(["archive"]),
coverFile: undefined,
});
@@ -1339,7 +1339,7 @@ const deriveHiddenCollectionSummaries = (
id: PseudoCollectionID.hiddenItems,
name: t("hidden_items"),
type: "hiddenItems",
- attributes: ["hiddenItems"],
+ attributes: new Set(["hiddenItems"]),
});
return hiddenCollectionSummaries;
@@ -1413,9 +1413,9 @@ const createCollectionSummaries = (
// This block of code duplicates the above. Such duplication is needed
// until type is completely replaced by attributes.
- const attributes: CollectionSummaryType[] = [];
+ const attributes = new Set<CollectionSummaryType>();
if (collection.owner.id != user.id) {
- attributes.push(
+ attributes.add(
collection.sharees.find((s) => s.id == user.id)?.role ==
"COLLABORATOR"
? "incomingShareCollaborator"
@@ -1423,19 +1423,19 @@ const createCollectionSummaries = (
);
}
if (isOutgoingShare(collection, user)) {
- attributes.push("outgoingShare");
+ attributes.add("outgoingShare");
}
if (isSharedOnlyViaLink(collection)) {
- attributes.push("sharedOnlyViaLink");
+ attributes.add("sharedOnlyViaLink");
}
if (isArchivedCollection(collection)) {
- attributes.push("archived");
+ attributes.add("archived");
}
if (isDefaultHiddenCollection(collection)) {
- attributes.push("defaultHidden");
+ attributes.add("defaultHidden");
}
if (isPinnedCollection(collection)) {
- attributes.push("pinned");
+ attributes.add("pinned");
}
switch (collectionType) {
case "favorites":
@@ -1443,10 +1443,10 @@ const createCollectionSummaries = (
// the user's own favorites (giving it a special icon etc), so
// only apply the favorites attribute if it is the user's own.
if (collection.owner.id == user.id)
- attributes.push(collectionType);
+ attributes.add(collectionType);
break;
default:
- attributes.push(collectionType);
+ attributes.add(collectionType);
break;
}
diff --git a/web/packages/new/photos/services/collection-summary.ts b/web/packages/new/photos/services/collection-summary.ts
index 1be023b8f5..22860b6ad6 100644
--- a/web/packages/new/photos/services/collection-summary.ts
+++ b/web/packages/new/photos/services/collection-summary.ts
@@ -117,7 +117,7 @@ export interface CollectionSummary {
* ad-hoc "UI" attributes which make it easier and more efficient for the UI
* elements to render the collection summary in the UI.
*/
- attributes: CollectionSummaryType[];
+ attributes: Set<CollectionSummaryType>;
/**
* The name of the collection or pseudo-collection surfaced in the UI.
*/