Skip to content

armgit / ente

Public Imported from GitHub
0

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

as attr

Manav Rathi5d594b49523f
diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
index a82b780fb1..19231e5b28 100644
--- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
@@ -85,18 +85,13 @@ export const CollectionHeader: React.FC<CollectionHeaderProps> = (props) => {
const { name, type, attributes, fileCount } = collectionSummary;
- const EndIcon = ({ type }: { type: CollectionSummaryType }) => {
+ const EndIcon = () => {
if (attributes.has("archived")) return <ArchiveOutlinedIcon />;
+ if (attributes.has("sharedOnlyViaLink")) return <LinkIcon />;
+ if (attributes.has("shared")) return <PeopleIcon />;
switch (type) {
case "favorites":
return <FavoriteRoundedIcon />;
- case "incomingShareViewer":
- case "incomingShareCollaborator":
- return <PeopleIcon />;
- case "outgoingShare":
- return <PeopleIcon />;
- case "sharedOnlyViaLink":
- return <LinkIcon />;
default:
return <></>;
}
@@ -108,7 +103,7 @@ export const CollectionHeader: React.FC<CollectionHeaderProps> = (props) => {
<GalleryItemsSummary
name={name}
fileCount={fileCount}
- endIcon={<EndIcon type={type} />}
+ endIcon={<EndIcon />}
/>
{shouldShowOptions(type) && (
<CollectionHeaderOptions {...props} />
@@ -570,6 +565,7 @@ const QuickOptions: React.FC<QuickOptionsProps> = ({
{showShareQuickOption(collectionSummary) && (
<ShareQuickOption
onClick={onShareClick}
+ collectionSummary={collectionSummary}
collectionSummaryType={type}
/>
)}
@@ -587,16 +583,13 @@ const EmptyTrashQuickOption: React.FC<OptionProps> = ({ onClick }) => (
</Tooltip>
);
-const showDownloadQuickOption = ({ type }: CollectionSummary) =>
+const showDownloadQuickOption = ({ type, attributes }: CollectionSummary) =>
type == "album" ||
type == "folder" ||
type == "favorites" ||
type == "uncategorized" ||
type == "hiddenItems" ||
- type == "incomingShareViewer" ||
- type == "incomingShareCollaborator" ||
- type == "outgoingShare" ||
- type == "sharedOnlyViaLink"
+ attributes.has("shared");
type DownloadQuickOptionProps = OptionProps & {
collectionSummaryType: CollectionSummaryType;
@@ -623,22 +616,21 @@ const DownloadQuickOption: React.FC<DownloadQuickOptionProps> = ({
</Tooltip>
);
-const showShareQuickOption = ({ type }: CollectionSummary) =>
+const showShareQuickOption = ({ type, attributes }: CollectionSummary) =>
type == "album" ||
type == "folder" ||
type == "favorites" ||
- type == "outgoingShare" ||
- type == "sharedOnlyViaLink" ||
- type == "incomingShareViewer" ||
- type == "incomingShareCollaborator"
+ attributes.has("shared");
interface ShareQuickOptionProps {
onClick: () => void;
+ collectionSummary: CollectionSummary;
collectionSummaryType: CollectionSummaryType;
}
const ShareQuickOption: React.FC<ShareQuickOptionProps> = ({
onClick,
+ collectionSummary,
collectionSummaryType,
}) => (
<Tooltip
@@ -646,8 +638,8 @@ const ShareQuickOption: React.FC<ShareQuickOptionProps> = ({
collectionSummaryType == "incomingShareViewer" ||
collectionSummaryType == "incomingShareCollaborator"
? t("sharing_details")
- : collectionSummaryType == "outgoingShare" ||
- collectionSummaryType == "sharedOnlyViaLink"
+ : collectionSummary.attributes.has("outgoingShare") ||
+ collectionSummary.attributes.has("sharedOnlyViaLink")
? t("modify_sharing")
: collectionSummaryType == "favorites"
? t("share_favorites")
diff --git a/web/packages/new/photos/components/gallery/BarImpl.tsx b/web/packages/new/photos/components/gallery/BarImpl.tsx
index 5d59a46326..7f9c5c6fda 100644
--- a/web/packages/new/photos/components/gallery/BarImpl.tsx
+++ b/web/packages/new/photos/components/gallery/BarImpl.tsx
@@ -543,10 +543,12 @@ const CollectionBarCardIcon: React.FC<CollectionBarCardIconProps> = ({
// Need && to override the 20px set in the container.
<PushPinIcon sx={{ "&&": { fontSize: "18px" } }} />
)}
- {(attributes.has("outgoingShare") ||
- attributes.has("incomingShareViewer") ||
- attributes.has("incomingShareCollaborator")) && <PeopleIcon />}
- {attributes.has("sharedOnlyViaLink") && <LinkIcon />}
+ {attributes.has("shared") &&
+ (attributes.has("sharedOnlyViaLink") ? (
+ <LinkIcon />
+ ) : (
+ <PeopleIcon />
+ ))}
{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 a274d53c2e..bd9e5f5821 100644
--- a/web/packages/new/photos/components/gallery/reducer.ts
+++ b/web/packages/new/photos/components/gallery/reducer.ts
@@ -1425,6 +1425,7 @@ const createCollectionSummaries = (
// until type is completely replaced by attributes.
const attributes = new Set<CollectionSummaryAttribute>();
if (collection.owner.id != user.id) {
+ attributes.add("shared");
attributes.add(
collection.sharees.find((s) => s.id == user.id)?.role ==
"COLLABORATOR"
@@ -1433,9 +1434,11 @@ const createCollectionSummaries = (
);
}
if (isOutgoingShare(collection, user)) {
+ attributes.add("shared");
attributes.add("outgoingShare");
}
if (isSharedOnlyViaLink(collection)) {
+ attributes.add("shared");
attributes.add("sharedOnlyViaLink");
}
if (isArchivedCollection(collection)) {
diff --git a/web/packages/new/photos/services/collection-summary.ts b/web/packages/new/photos/services/collection-summary.ts
index aba70552f7..46ea092163 100644
--- a/web/packages/new/photos/services/collection-summary.ts
+++ b/web/packages/new/photos/services/collection-summary.ts
@@ -20,6 +20,7 @@ export type CollectionSummaryAttribute =
| "trash"
| "hiddenItems"
| "defaultHidden"
+ | "shared"
| "outgoingShare"
| "incomingShareViewer"
| "incomingShareCollaborator"