Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix(FileInfo):show-hidden-pill-in-albums

Aswin Asok66d63af79cac
diff --git a/desktop/changes/show-hidden-albums-in-file-info.md b/desktop/changes/show-hidden-albums-in-file-info.md
new file mode 100644
index 0000000000..c5955aea9e
--- /dev/null
+++ b/desktop/changes/show-hidden-albums-in-file-info.md
@@ -0,0 +1 @@
+- Show hidden album presence in the File Info panel.
diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsx
index e61208430c..269fd26f01 100644
--- a/web/apps/photos/src/components/FileListWithViewer.tsx
+++ b/web/apps/photos/src/components/FileListWithViewer.tsx
@@ -131,6 +131,8 @@ export type FileListWithViewerProps = {
| "isInIncomingSharedCollection"
| "isInHiddenSection"
| "fileNormalCollectionIDs"
+ | "fileCollectionIDs"
+ | "hiddenCollectionIDs"
| "collectionSummaries"
| "collectionNameByID"
| "pendingFavoriteUpdates"
@@ -177,6 +179,8 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
isInIncomingSharedCollection,
isInHiddenSection,
fileNormalCollectionIDs,
+ fileCollectionIDs,
+ hiddenCollectionIDs,
collectionSummaries,
collectionNameByID,
pendingFavoriteUpdates,
@@ -392,6 +396,8 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
isInIncomingSharedCollection,
favoriteFileIDs,
fileNormalCollectionIDs,
+ fileCollectionIDs,
+ hiddenCollectionIDs,
collectionSummaries,
collectionNameByID,
pendingFavoriteUpdates,
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index bc4b4cd89d..b371b552e3 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -396,6 +396,7 @@ const Page: React.FC = () => {
favoriteFileIDs,
collectionNameByID,
fileNormalCollectionIDs,
+ hiddenCollectionIDs,
normalCollectionSummaries,
hiddenFileIDs,
tempDeletedFileIDs,
@@ -421,6 +422,21 @@ const Page: React.FC = () => {
const activePerson =
state.view?.type == "people" ? state.view.activePerson : undefined;
const activePersonID = activePerson?.id;
+ const fileCollectionIDs = useMemo(
+ () =>
+ state.collectionFiles.reduce((result, file) => {
+ const collectionIDs = result.get(file.id);
+ if (collectionIDs) {
+ if (!collectionIDs.includes(file.collectionID)) {
+ collectionIDs.push(file.collectionID);
+ }
+ } else {
+ result.set(file.id, [file.collectionID]);
+ }
+ return result;
+ }, new Map<number, number[]>()),
+ [state.collectionFiles],
+ );
/**
* the below function is used to conditionallay render the setCover option in the dropdown
@@ -2223,6 +2239,8 @@ const Page: React.FC = () => {
favoriteFileIDs,
collectionNameByID,
fileNormalCollectionIDs,
+ fileCollectionIDs,
+ hiddenCollectionIDs,
pendingFavoriteUpdates,
pendingVisibilityUpdates,
onAddSaveGroup,
diff --git a/web/packages/gallery/components/FileInfo.tsx b/web/packages/gallery/components/FileInfo.tsx
index e1e91d19b4..4bcbbc377d 100644
--- a/web/packages/gallery/components/FileInfo.tsx
+++ b/web/packages/gallery/components/FileInfo.tsx
@@ -135,8 +135,8 @@ export type FileInfoProps = ModalVisibilityProps & {
*/
allowMap?: boolean;
/**
- * If set, then a clickable chip will be shown for each normal collection
- * that this file is a part of.
+ * If set, then a chip will be shown for each collection that this file is
+ * a part of.
*
* Uses {@link fileCollectionIDs}, {@link collectionNameByID} and
* {@link onSelectCollection}, so all of those props should also be set for
@@ -155,6 +155,12 @@ export type FileInfoProps = ModalVisibilityProps & {
* Used when {@link showCollections} is set.
*/
collectionNameByID?: Map<number, string>;
+ /**
+ * IDs of hidden collections.
+ *
+ * Used when {@link showCollections} is set.
+ */
+ hiddenCollectionIDs?: Set<number>;
/**
* Called when the action on the file info drawer has changed some metadata
* for a file.
@@ -204,6 +210,7 @@ export const FileInfo: React.FC<FileInfoProps> = ({
showCollections,
fileCollectionIDs,
collectionNameByID,
+ hiddenCollectionIDs,
onFileMetadataUpdate,
onUpdateCaption,
onSelectCollection,
@@ -484,6 +491,7 @@ export const FileInfo: React.FC<FileInfoProps> = ({
file,
fileCollectionIDs,
collectionNameByID,
+ hiddenCollectionIDs,
onSelectCollection,
}}
/>
@@ -1301,12 +1309,13 @@ type AlbumsProps = Required<
FileInfoProps,
"fileCollectionIDs" | "collectionNameByID" | "onSelectCollection"
>
-> & { file: EnteFile };
+> & { file: EnteFile; hiddenCollectionIDs?: Set<number> };
const Albums: React.FC<AlbumsProps> = ({
file,
fileCollectionIDs,
collectionNameByID,
+ hiddenCollectionIDs,
onSelectCollection,
}) => (
<InfoItem icon={<FolderOutlinedIcon />}>
@@ -1322,14 +1331,24 @@ const Albums: React.FC<AlbumsProps> = ({
{fileCollectionIDs
.get(file.id)
?.filter((collectionID) => collectionNameByID.has(collectionID))
- .map((collectionID) => (
- <ChipButton
- key={collectionID}
- onClick={() => onSelectCollection(collectionID)}
- >
- {collectionNameByID.get(collectionID)}
- </ChipButton>
- ))}
+ .map((collectionID) => {
+ const isHiddenCollection =
+ hiddenCollectionIDs?.has(collectionID);
+ return (
+ <ChipButton
+ key={collectionID}
+ onClick={() => {
+ if (!isHiddenCollection) {
+ onSelectCollection(collectionID);
+ }
+ }}
+ >
+ {isHiddenCollection
+ ? t("section_hidden")
+ : collectionNameByID.get(collectionID)}
+ </ChipButton>
+ );
+ })}
</Stack>
</InfoItem>
);
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx
index 28297e7260..ce0df2d831 100644
--- a/web/packages/gallery/components/viewer/FileViewer.tsx
+++ b/web/packages/gallery/components/viewer/FileViewer.tsx
@@ -248,6 +248,14 @@ export type FileViewerProps = ModalVisibilityProps & {
* that they are a part of.
*/
fileNormalCollectionIDs?: FileInfoProps["fileCollectionIDs"];
+ /**
+ * A mapping from file IDs to all collection IDs that they are a part of.
+ */
+ fileCollectionIDs?: FileInfoProps["fileCollectionIDs"];
+ /**
+ * IDs of hidden collections.
+ */
+ hiddenCollectionIDs?: FileInfoProps["hiddenCollectionIDs"];
/**
* Collection summaries indexed by their IDs.
*/
@@ -393,6 +401,8 @@ export const FileViewer: React.FC<FileViewerProps> = ({
pendingFavoriteUpdates,
pendingVisibilityUpdates,
fileNormalCollectionIDs,
+ fileCollectionIDs,
+ hiddenCollectionIDs,
collectionSummaries,
collectionNameByID,
onTriggerRemotePull,
@@ -2144,8 +2154,9 @@ export const FileViewer: React.FC<FileViewerProps> = ({
exif={activeFileExif}
allowEdits={activeAnnotatedFile.annotation.isOwnFile}
allowMap={haveUser}
- showCollections={haveUser && !isInHiddenSection}
- fileCollectionIDs={fileNormalCollectionIDs}
+ showCollections={haveUser}
+ fileCollectionIDs={fileCollectionIDs ?? fileNormalCollectionIDs}
+ hiddenCollectionIDs={hiddenCollectionIDs}
onFileMetadataUpdate={handleFileMetadataUpdate}
onUpdateCaption={handleUpdateCaption}
onSelectCollection={handleSelectCollection}