Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix(gallery):show-only-archieved-album-in-archived-section-header

Aswin Asokac15dc518665
diff --git a/web/apps/photos/src/components/Collections/AllAlbums.tsx b/web/apps/photos/src/components/Collections/AllAlbums.tsx
index 48eb83a04c..98906906be 100644
--- a/web/apps/photos/src/components/Collections/AllAlbums.tsx
+++ b/web/apps/photos/src/components/Collections/AllAlbums.tsx
@@ -58,6 +58,7 @@ interface AllAlbums {
collectionsSortBy: CollectionsSortBy;
onChangeCollectionsSortBy: (by: CollectionsSortBy) => void;
isInHiddenSection: boolean;
+ canCreateAlbum: boolean;
onRemotePull: () => Promise<void>;
}
@@ -72,6 +73,7 @@ export const AllAlbums: React.FC<AllAlbums> = ({
collectionsSortBy,
onChangeCollectionsSortBy,
isInHiddenSection,
+ canCreateAlbum,
onRemotePull,
}) => {
const fullScreen = useMediaQuery("(max-width: 428px)");
@@ -130,13 +132,14 @@ export const AllAlbums: React.FC<AllAlbums> = ({
}, [collectionSummaries, searchTerm]);
const showCreateButton = useMemo(() => {
+ if (!canCreateAlbum) return false;
if (!searchTerm.trim()) {
return true;
}
const searchLower = searchTerm.toLowerCase();
const createText = t("new_album").toLowerCase();
return createText.includes(searchLower);
- }, [searchTerm]);
+ }, [canCreateAlbum, searchTerm]);
return (
<>
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
index 548350e84e..8abece870d 100644
--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
@@ -65,6 +65,7 @@ type GalleryBarAndListHeaderProps = Omit<
setActiveCollectionID: (collectionID: number) => void;
setFileListHeader: (header: FileListHeaderOrFooter) => void;
saveGroups: SaveGroup[];
+ canCreateAlbum: boolean;
} & Pick<
CollectionHeaderProps,
| "files"
@@ -120,6 +121,7 @@ export const GalleryBarAndListHeader: React.FC<
people,
allPeople,
saveGroups,
+ canCreateAlbum,
files,
mapFileSource,
activePerson,
@@ -326,6 +328,7 @@ export const GalleryBarAndListHeader: React.FC<
onChangeCollectionsSortBy={setCollectionsSortBy}
collectionsSortBy={collectionsSortBy}
isInHiddenSection={mode == "hidden-albums"}
+ canCreateAlbum={canCreateAlbum}
onRemotePull={onRemotePull}
/>
<AllPeople
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 500b268d75..bf38824cb1 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -496,18 +496,45 @@ const Page: React.FC = () => {
filteredFiles.length > 0 &&
selectedFilesInView.length === filteredFiles.length;
+ const isInArchiveSection =
+ barMode == "albums" &&
+ (activeCollectionID == PseudoCollectionID.archiveItems ||
+ activeCollectionSummary?.attributes.has("archived"));
+
// TODO: Move into reducer
- const barCollectionSummaries = useMemo(
- () =>
- barMode == "hidden-albums"
- ? state.hiddenCollectionSummaries
- : state.normalCollectionSummaries,
- [
- barMode,
- state.hiddenCollectionSummaries,
- state.normalCollectionSummaries,
- ],
- );
+ const barCollectionSummaries = useMemo(() => {
+ if (barMode == "hidden-albums") return state.hiddenCollectionSummaries;
+ if (!isInArchiveSection) return state.normalCollectionSummaries;
+
+ const archiveCollectionSummaries = new Map(
+ [...state.normalCollectionSummaries].filter(
+ ([id, collectionSummary]) =>
+ id == PseudoCollectionID.archiveItems ||
+ collectionSummary.attributes.has("archived"),
+ ),
+ );
+ const archiveSummary = archiveCollectionSummaries.get(
+ PseudoCollectionID.archiveItems,
+ );
+ if (archiveSummary) {
+ archiveCollectionSummaries.set(PseudoCollectionID.archiveItems, {
+ ...archiveSummary,
+ coverFile:
+ archiveSummary.coverFile ?? archiveSummary.latestFile,
+ attributes: new Set(
+ [...archiveSummary.attributes].filter(
+ (attribute) => attribute != "hideFromCollectionBar",
+ ),
+ ),
+ });
+ }
+ return archiveCollectionSummaries;
+ }, [
+ barMode,
+ isInArchiveSection,
+ state.hiddenCollectionSummaries,
+ state.normalCollectionSummaries,
+ ]);
const router = useRouter();
@@ -2046,10 +2073,17 @@ const Page: React.FC = () => {
onEditLocation={showEditLocation}
/>
) : barMode == "hidden-albums" ? (
- <HiddenSectionNavbarContents
+ <SectionNavbarContents
+ title={t("section_hidden")}
onBack={() => dispatch({ type: "showAlbums" })}
onUpload={openUploader}
/>
+ ) : !isInSearchMode && isInArchiveSection ? (
+ <SectionNavbarContents
+ title={t("section_archive")}
+ onBack={() => dispatch({ type: "showAll" })}
+ onUpload={openUploader}
+ />
) : (
<NormalNavbarContents
{...{ isInSearchMode }}
@@ -2081,6 +2115,7 @@ const Page: React.FC = () => {
activePerson,
setFileListHeader,
saveGroups,
+ canCreateAlbum: !isInArchiveSection,
onAddSaveGroup,
onMarkTempDeleted: handleMarkTempDeleted,
onAddFileToCollection: handleAddSingleFileToCollection,
@@ -2376,14 +2411,17 @@ const UploadButton: React.FC<ButtonishProps> = ({ onClick }) => {
);
};
-interface HiddenSectionNavbarContentsProps {
+interface SectionNavbarContentsProps {
+ title: string;
onBack: () => void;
onUpload: () => void;
}
-const HiddenSectionNavbarContents: React.FC<
- HiddenSectionNavbarContentsProps
-> = ({ onBack, onUpload }) => (
+const SectionNavbarContents: React.FC<SectionNavbarContentsProps> = ({
+ title,
+ onBack,
+ onUpload,
+}) => (
<Stack
direction="row"
sx={(theme) => ({
@@ -2396,7 +2434,7 @@ const HiddenSectionNavbarContents: React.FC<
<IconButton onClick={onBack}>
<ArrowBackIcon />
</IconButton>
- <Typography sx={{ flex: 1 }}>{t("section_hidden")}</Typography>
+ <Typography sx={{ flex: 1 }}>{title}</Typography>
<UploadButton onClick={onUpload} />
</Stack>
);