Skip to content

armgit / ente

Public Imported from GitHub
0

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

Improve public album masonry behavior and layout settings

Anand Baburajan44617f010555
diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsx
index 463bf0b9b3..54c6ea2977 100644
--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx
@@ -1559,14 +1559,20 @@ const EnablePublicShareOptions: React.FC<EnablePublicShareOptionsProps> = ({
setErrorMessage("");
setPending(attributes ? "collect" : "link");
- void createPublicURL(collection.id, attributes)
- .then((publicURL) => {
+ void (async () => {
+ try {
+ const normalizedLayout = normalizedLayoutValue(
+ collection.pubMagicMetadata?.data.layout,
+ );
+ if (collection.pubMagicMetadata?.data.layout !== normalizedLayout) {
+ await updateCollectionLayout(collection, normalizedLayout);
+ }
+ const publicURL = await createPublicURL(collection.id, attributes);
setPending("");
setPublicURL(publicURL);
onLinkCreated();
void onRemotePull({ silent: true });
- })
- .catch((e: unknown) => {
+ } catch (e: unknown) {
log.error("Could not create public link", e);
setErrorMessage(
isHTTPErrorWithStatus(e, 402)
@@ -1574,7 +1580,8 @@ const EnablePublicShareOptions: React.FC<EnablePublicShareOptionsProps> = ({
: t("generic_error"),
);
setPending("");
- });
+ }
+ })();
};
return (
@@ -2300,8 +2307,9 @@ const ManageLayout: React.FC<ManageLayoutProps> = ({
const options = useMemo(() => layoutOptions(), []);
- const currentLayout =
- collection.pubMagicMetadata?.data?.layout || "grouped";
+ const currentLayout = normalizedLayoutValue(
+ collection.pubMagicMetadata?.data?.layout,
+ );
const changeLayoutValue = (value: string) => async () => {
if (value === currentLayout) return;
@@ -2326,7 +2334,7 @@ const ManageLayout: React.FC<ManageLayoutProps> = ({
<RowButtonGroup>
<RowButton
label={t("album_layout")}
- caption={t(currentLayout)}
+ caption={layoutLabel(currentLayout)}
onClick={showLayoutOptions}
endIcon={<ChevronRightIcon />}
/>
@@ -2387,7 +2395,19 @@ const ManageLayout: React.FC<ManageLayoutProps> = ({
};
const layoutOptions = () => [
+ { label: layoutLabel("masonry"), value: "masonry" },
{ label: t("grouped"), value: "grouped" },
- { label: t("continuous"), value: "continuous" },
{ label: t("trip"), value: "trip" },
];
+
+const normalizedLayoutValue = (layout: string | undefined) => {
+ if (layout === "grouped" || layout === "trip" || layout === "masonry") {
+ return layout;
+ }
+ return "masonry";
+};
+
+const layoutLabel = (layout: string) =>
+ layout === "masonry"
+ ? t("masonry", { defaultValue: "Masonry" })
+ : t(layout);
diff --git a/web/apps/photos/src/components/FileList.tsx b/web/apps/photos/src/components/FileList.tsx
index 46f7520242..6ae1a5c6e4 100644
--- a/web/apps/photos/src/components/FileList.tsx
+++ b/web/apps/photos/src/components/FileList.tsx
@@ -167,6 +167,27 @@ export type EnteTrashFile = EnteFile & {
deleteBy?: number;
};
+interface MasonryLayoutItem {
+ file: EnteFile;
+ fileIndex: number;
+ left: number;
+ top: number;
+ bottom: number;
+ width: number;
+ height: number;
+}
+
+interface MasonryLayout {
+ items: MasonryLayoutItem[];
+ columns: MasonryLayoutItem[][];
+ totalHeight: number;
+}
+
+interface Dimensions {
+ width: number;
+ height: number;
+}
+
export interface FileListProps {
/** The height we should occupy (needed since the list is virtualized). */
height: number;
@@ -188,6 +209,10 @@ export interface FileListProps {
* another mode in which the gallery operates.
*/
modePlus?: GalleryBarMode | "search";
+ /**
+ * The visual layout used to render the file listing.
+ */
+ layout?: "grid" | "masonry";
/**
* An optional component shown before all the items in the list.
*
@@ -299,6 +324,7 @@ export const FileList: React.FC<FileListProps> = ({
listBorderRadius,
mode,
modePlus,
+ layout = "grid",
header,
footer,
user,
@@ -329,6 +355,10 @@ export const FileList: React.FC<FileListProps> = ({
);
const [hoverIndex, setHoverIndex] = useState<number | undefined>(undefined);
const [isShiftKeyPressed, setIsShiftKeyPressed] = useState(false);
+ const [masonryScrollTop, setMasonryScrollTop] = useState(0);
+ const [masonryDimensionsByFileID, setMasonryDimensionsByFileID] = useState<
+ Map<number, Dimensions>
+ >(new Map());
// Timeline date strings for which all photos have been selected.
//
// See: [Note: Timeline date string]
@@ -363,8 +393,14 @@ export const FileList: React.FC<FileListProps> = ({
() => computeThumbnailGridLayoutParams(width),
[width],
);
+ const shouldUseMasonry = layout === "masonry";
useEffect(() => {
+ if (shouldUseMasonry) {
+ setItems([]);
+ return;
+ }
+
// Since width and height are dependencies, there might be too many
// updates to the list during a resize. The list computation too, while
// fast, is non-trivial.
@@ -512,6 +548,7 @@ export const FileList: React.FC<FileListProps> = ({
footer,
annotatedFiles,
disableGrouping,
+ shouldUseMasonry,
layoutParams,
]);
@@ -600,6 +637,25 @@ export const FileList: React.FC<FileListProps> = ({
[setSelected, mode, user?.id, activeCollectionID, activePersonID],
);
+ const isSelectionContextMatching = useMemo(() => {
+ if (!mode) return selected.collectionID === activeCollectionID;
+ if (mode !== selected.context?.mode) return false;
+ if (selected.context.mode === "people") {
+ return selected.context.personID === activePersonID;
+ }
+ return selected.context.collectionID === activeCollectionID;
+ }, [activeCollectionID, activePersonID, mode, selected]);
+
+ const isFileSelected = useCallback(
+ (file: EnteFile) => {
+ if (suppressSelectionUI) return false;
+ return isSelectionContextMatching && !!selected[file.id];
+ },
+ [isSelectionContextMatching, selected, suppressSelectionUI],
+ );
+
+ const haveSelection = !suppressSelectionUI && selected.count > 0;
+
const handleRangeSelect = useCallback(
(index: number) => {
if (rangeStartIndex === undefined || rangeStartIndex == index)
@@ -794,7 +850,6 @@ export const FileList: React.FC<FileListProps> = ({
const renderListItem = useCallback(
(item: FileListItem, isScrolling: boolean) => {
- const haveSelection = !suppressSelectionUI && selected.count > 0;
const showGroupCheckbox =
haveSelection && !(contextMenu && selected.count === 1);
switch (item.type) {
@@ -840,23 +895,7 @@ export const FileList: React.FC<FileListProps> = ({
!suppressSelectionUI,
}}
file={file}
- selected={
- !suppressSelectionUI &&
- (!mode
- ? selected.collectionID ===
- activeCollectionID
- : mode ==
- selected.context?.mode &&
- (selected.context.mode ==
- "people"
- ? selected.context
- .personID ==
- activePersonID
- : selected.context
- .collectionID ==
- activeCollectionID)) &&
- !!selected[file.id]
- }
+ selected={isFileSelected(file)}
selectOnClick={haveSelection}
isRangeSelectActive={
isShiftKeyPressed && haveSelection
@@ -901,24 +940,24 @@ export const FileList: React.FC<FileListProps> = ({
},
[
activeCollectionID,
- activePersonID,
checkedTimelineDateStrings,
contextMenu,
emailByUserID,
favoriteFileIDs,
+ haveSelection,
handleContextMenu,
handleRangeSelect,
handleSelect,
hoverIndex,
isShiftKeyPressed,
- mode,
+ isFileSelected,
onChangeSelectAllCheckBox,
onContextMenuAction,
onItemClick,
rangeStartIndex,
enableSelect,
- suppressSelectionUI,
selected,
+ suppressSelectionUI,
user,
],
);
@@ -981,10 +1020,346 @@ export const FileList: React.FC<FileListProps> = ({
[onScroll, onVisibleDateChange, items],
);
+ useEffect(() => {
+ if (!shouldUseMasonry) {
+ setMasonryDimensionsByFileID(new Map());
+ return;
+ }
+
+ const validFileIDs = new Set(annotatedFiles.map(({ file }) => file.id));
+ setMasonryDimensionsByFileID((prev) => {
+ if (prev.size === 0) return prev;
+ const next = new Map(prev);
+ for (const fileID of next.keys()) {
+ if (!validFileIDs.has(fileID)) next.delete(fileID);
+ }
+ return next.size === prev.size ? prev : next;
+ });
+ }, [annotatedFiles, shouldUseMasonry]);
+
+ const updateMasonryDimensions = useCallback(
+ (fileID: number, dimensions: Dimensions) => {
+ if (dimensions.width <= 0 || dimensions.height <= 0) return;
+ setMasonryDimensionsByFileID((prev) => {
+ const existing = prev.get(fileID);
+ if (
+ existing &&
+ existing.width === dimensions.width &&
+ existing.height === dimensions.height
+ ) {
+ return prev;
+ }
+ const next = new Map(prev);
+ next.set(fileID, dimensions);
+ return next;
+ });
+ },
+ [],
+ );
+
+ const masonryColumns = useMemo(
+ () => preferredMasonryColumns(layoutParams.containerWidth),
+ [layoutParams.containerWidth],
+ );
+ const masonryInnerWidth = useMemo(
+ () => Math.max(0, width - 2 * layoutParams.paddingInline),
+ [layoutParams.paddingInline, width],
+ );
+ const masonryItemWidth = useMemo(() => {
+ if (masonryColumns < 1) return 0;
+ return (
+ (masonryInnerWidth - (masonryColumns - 1) * layoutParams.gap) /
+ masonryColumns
+ );
+ }, [layoutParams.gap, masonryColumns, masonryInnerWidth]);
+ const masonryLayout = useMemo<MasonryLayout>(() => {
+ if (
+ !shouldUseMasonry ||
+ masonryItemWidth <= 0 ||
+ !annotatedFiles.length
+ ) {
+ return { items: [], columns: [], totalHeight: 0 };
+ }
+
+ const columnHeights = Array.from({ length: masonryColumns }, () => 0);
+ const columns = Array.from({ length: masonryColumns }, () =>
+ new Array<MasonryLayoutItem>(),
+ );
+ const items: MasonryLayoutItem[] = [];
+
+ for (const [fileIndex, { file }] of annotatedFiles.entries()) {
+ const dimensions = fileMasonryDimensions(
+ file,
+ masonryDimensionsByFileID.get(file.id),
+ );
+ const itemHeight = Math.max(
+ 1,
+ (masonryItemWidth * dimensions.height) / dimensions.width,
+ );
+ const targetColumn = shortestColumnIndex(columnHeights);
+ const top = columnHeights[targetColumn]!;
+ const bottom = top + itemHeight;
+ const left = targetColumn * (masonryItemWidth + layoutParams.gap);
+
+ const item = {
+ file,
+ fileIndex,
+ top,
+ bottom,
+ left,
+ width: masonryItemWidth,
+ height: itemHeight,
+ } satisfies MasonryLayoutItem;
+ items.push(item);
+ columns[targetColumn]!.push(item);
+
+ columnHeights[targetColumn] = top + itemHeight + layoutParams.gap;
+ }
+
+ const totalHeight = Math.max(
+ 0,
+ Math.max(...columnHeights) - layoutParams.gap,
+ );
+ return { items, columns, totalHeight };
+ }, [
+ annotatedFiles,
+ layoutParams.gap,
+ masonryColumns,
+ masonryDimensionsByFileID,
+ masonryItemWidth,
+ shouldUseMasonry,
+ ]);
+ const masonryHeaderHeight = header?.height ?? 0;
+ const masonryViewportTop = Math.max(
+ 0,
+ masonryScrollTop - masonryHeaderHeight,
+ );
+ const masonryViewportBottom = masonryViewportTop + height;
+ const masonryOverscan = Math.max(height, 800);
+ const masonryVisibleItems = useMemo(
+ () => {
+ const minTop = masonryViewportTop - masonryOverscan;
+ const maxTop = masonryViewportBottom + masonryOverscan;
+ const visible = new Array<MasonryLayoutItem>();
+
+ for (const column of masonryLayout.columns) {
+ const startIndex = firstVisibleIndexForColumn(column, minTop);
+ for (let i = startIndex; i < column.length; i += 1) {
+ const item = column[i]!;
+ if (item.top > maxTop) break;
+ visible.push(item);
+ }
+ }
+
+ return visible;
+ },
+ [
+ masonryLayout.columns,
+ masonryOverscan,
+ masonryViewportBottom,
+ masonryViewportTop,
+ ],
+ );
+
+ const handleMasonryScroll: React.UIEventHandler<HTMLDivElement> =
+ useCallback(
+ (event) => {
+ const scrollOffset = event.currentTarget.scrollTop;
+ onScroll?.(scrollOffset);
+ setShowBackToTop(scrollOffset > 500);
+ setMasonryScrollTop(scrollOffset);
+ },
+ [onScroll],
+ );
+
+ useEffect(() => {
+ if (!shouldUseMasonry) {
+ setMasonryScrollTop(0);
+ }
+ }, [shouldUseMasonry]);
+
+ useEffect(() => {
+ if (!shouldUseMasonry || !onVisibleDateChange) return;
+ const topVisibleItem = masonryVisibleItems.reduce<
+ MasonryLayoutItem | undefined
+ >(
+ (best, item) =>
+ item.bottom > masonryViewportTop &&
+ (!best || item.top < best.top)
+ ? item
+ : best,
+ undefined,
+ );
+ const visibleDate =
+ topVisibleItem &&
+ annotatedFiles[topVisibleItem.fileIndex]?.timelineDateString;
+ const currentDate =
+ visibleDate ?? annotatedFiles[0]?.timelineDateString;
+ if (currentDate !== lastVisibleDateRef.current) {
+ lastVisibleDateRef.current = currentDate;
+ onVisibleDateChange(currentDate);
+ }
+ }, [
+ annotatedFiles,
+ masonryVisibleItems,
+ masonryViewportTop,
+ onVisibleDateChange,
+ shouldUseMasonry,
+ ]);
+
+ const renderMasonryItem = useCallback(
+ ({ file, fileIndex, top, left, width, height }: MasonryLayoutItem) => {
+ return (
+ <Box
+ key={`masonry-photo-${file.id}-${fileIndex}`}
+ sx={{ position: "absolute", top, left, width, height }}
+ >
+ <FileThumbnail
+ key={`tile-${file.id}-selected-${selected[file.id] ?? false}`}
+ {...{
+ user,
+ emailByUserID,
+ enableSelect:
+ !!enableSelect && !suppressSelectionUI,
+ }}
+ file={file}
+ selected={isFileSelected(file)}
+ selectOnClick={haveSelection}
+ isRangeSelectActive={isShiftKeyPressed && haveSelection}
+ isInSelectRange={
+ rangeStartIndex !== undefined &&
+ hoverIndex !== undefined &&
+ ((fileIndex >= rangeStartIndex &&
+ fileIndex <= hoverIndex) ||
+ (fileIndex >= hoverIndex &&
+ fileIndex <= rangeStartIndex))
+ }
+ activeCollectionID={activeCollectionID}
+ showPlaceholder={false}
+ isFav={!!favoriteFileIDs?.has(file.id)}
+ onClick={() => onItemClick(fileIndex)}
+ onSelect={handleSelect(file, fileIndex)}
+ onHover={() => setHoverIndex(fileIndex)}
+ onRangeSelect={() => handleRangeSelect(fileIndex)}
+ onContextMenu={
+ onContextMenuAction
+ ? (e) => handleContextMenu(e, file, fileIndex)
+ : undefined
+ }
+ onImageDimensions={(dimensions) =>
+ updateMasonryDimensions(file.id, dimensions)
+ }
+ isMasonry
+ style={{ width: "100%", height: "100%" }}
+ />
+ </Box>
+ );
+ },
+ [
+ activeCollectionID,
+ emailByUserID,
+ enableSelect,
+ favoriteFileIDs,
+ handleContextMenu,
+ handleRangeSelect,
+ handleSelect,
+ haveSelection,
+ hoverIndex,
+ isFileSelected,
+ isShiftKeyPressed,
+ onContextMenuAction,
+ onItemClick,
+ rangeStartIndex,
+ selected,
+ suppressSelectionUI,
+ updateMasonryDimensions,
+ user,
+ ],
+ );
+
const handleScrollToTop = useCallback(() => {
outerRef.current?.scrollTo({ top: 0, behavior: "smooth" });
}, []);
+ if (shouldUseMasonry) {
+ return (
+ <Box sx={{ position: "relative", width, height }}>
+ <Box
+ ref={outerRef}
+ sx={{
+ width: "100%",
+ height: "100%",
+ overflowY: "auto",
+ ...(listBorderRadius && {
+ borderRadius: listBorderRadius,
+ }),
+ }}
+ onScroll={handleMasonryScroll}
+ >
+ {header && (
+ <Box
+ sx={{
+ px: header.extendToInlineEdges
+ ? 0
+ : `${layoutParams.paddingInline}px`,
+ }}
+ >
+ {header.component}
+ </Box>
+ )}
+ {masonryLayout.items.length > 0 ? (
+ <Box sx={{ px: `${layoutParams.paddingInline}px` }}>
+ <Box
+ sx={{
+ width: masonryInnerWidth,
+ position: "relative",
+ height: masonryLayout.totalHeight,
+ }}
+ >
+ {masonryVisibleItems.map(renderMasonryItem)}
+ </Box>
+ </Box>
+ ) : (
+ <NoFilesListItem sx={{ minHeight: "100%" }}>
+ <Typography sx={{ color: "text.faint" }}>
+ {t("nothing_here")}
+ </Typography>
+ </NoFilesListItem>
+ )}
+ {footer && (
+ <Box
+ sx={{
+ px: footer.extendToInlineEdges
+ ? 0
+ : `${layoutParams.paddingInline}px`,
+ }}
+ >
+ {footer.component}
+ </Box>
+ )}
+ </Box>
+ {showBackToTop && (
+ <BackToTopButton
+ size="small"
+ aria-label="scroll to top"
+ onClick={handleScrollToTop}
+ >
+ <KeyboardArrowUpIcon />
+ </BackToTopButton>
+ )}
+ {onContextMenuAction && (
+ <FileContextMenu
+ open={contextMenu !== null}
+ anchorPosition={contextMenu?.position}
+ onClose={handleContextMenuClose}
+ actions={contextMenuActions}
+ onAction={handleContextMenuActionWithTracking}
+ />
+ )}
+ </Box>
+ );
+ }
+
if (!items.length) {
return <></>;
}
@@ -1062,6 +1437,57 @@ const splitByDate = (annotatedFiles: FileListAnnotatedFile[]) =>
new Array<FileListAnnotatedFile[]>(),
);
+const shortestColumnIndex = (columnHeights: number[]) =>
+ columnHeights.reduce(
+ (minColumn, height, index) =>
+ height < columnHeights[minColumn]! ? index : minColumn,
+ 0,
+ );
+
+const firstVisibleIndexForColumn = (
+ column: MasonryLayoutItem[],
+ minTop: number,
+) => {
+ let low = 0;
+ let high = column.length;
+ while (low < high) {
+ const mid = Math.floor((low + high) / 2);
+ if (column[mid]!.bottom < minTop) {
+ low = mid + 1;
+ } else {
+ high = mid;
+ }
+ }
+ return low;
+};
+
+const fileMasonryDimensions = (
+ file: EnteFile,
+ inferredDimensions?: Dimensions,
+) => {
+ if (inferredDimensions) return inferredDimensions;
+
+ const width = file.pubMagicMetadata?.data.w;
+ const height = file.pubMagicMetadata?.data.h;
+ if (width && height && width > 0 && height > 0) {
+ return { width, height };
+ }
+
+ if (file.metadata.fileType === FileType.video) {
+ return { width: 16, height: 9 };
+ }
+
+ return { width: 4, height: 3 };
+};
+
+const preferredMasonryColumns = (containerWidth: number) => {
+ if (containerWidth < 560) return 2;
+ if (containerWidth < 900) return 3;
+ if (containerWidth < 1280) return 4;
+ if (containerWidth < 1800) return 5;
+ return 6;
+};
+
/**
* For each element of {@link xs}, obtain an array by applying {@link f},
* then obtain a gap element by applying {@link g}. Return a flattened array
@@ -1208,6 +1634,9 @@ type FileThumbnailProps = {
onHover: () => void;
onRangeSelect: () => void;
onContextMenu?: (event: React.MouseEvent) => void;
+ onImageDimensions?: (dimensions: Dimensions) => void;
+ isMasonry?: boolean;
+ style?: React.CSSProperties;
} & Pick<FileListProps, "user" | "emailByUserID" | "enableSelect">;
const FileThumbnail: React.FC<FileThumbnailProps> = ({
@@ -1227,6 +1656,9 @@ const FileThumbnail: React.FC<FileThumbnailProps> = ({
onHover,
onRangeSelect,
onContextMenu,
+ onImageDimensions,
+ isMasonry,
+ style,
}) => {
const [imageURL, setImageURL] = useState<string | undefined>(undefined);
const [isLongPressing, setIsLongPressing] = useState(false);
@@ -1306,6 +1738,8 @@ const FileThumbnail: React.FC<FileThumbnailProps> = ({
onContextMenu={onContextMenu}
onMouseEnter={handleHover}
disabled={!imageURL}
+ $disableBottomMargin={!!isMasonry}
+ style={style}
{...(enableSelect && longPressHandlers)}
>
{enableSelect && (
@@ -1320,7 +1754,17 @@ const FileThumbnail: React.FC<FileThumbnailProps> = ({
{file.metadata.hasStaticThumbnail ? (
<StaticThumbnail fileType={file.metadata.fileType} />
) : imageURL ? (
- <img src={imageURL} />
+ <img
+ src={imageURL}
+ onLoad={(event) => {
+ const { naturalWidth, naturalHeight } =
+ event.currentTarget;
+ onImageDimensions?.({
+ width: naturalWidth,
+ height: naturalHeight,
+ });
+ }}
+ />
) : (
<LoadingThumbnail />
)}
@@ -1362,10 +1806,14 @@ const FileThumbnail: React.FC<FileThumbnailProps> = ({
);
};
-const FileThumbnail_ = styled("div")<{ disabled: boolean }>`
+const FileThumbnail_ = styled("div")<{
+ disabled: boolean;
+ $disableBottomMargin: boolean;
+}>`
display: flex;
width: fit-content;
- margin-bottom: ${thumbnailGap}px;
+ margin-bottom: ${({ $disableBottomMargin }) =>
+ $disableBottomMargin ? "0px" : `${thumbnailGap}px`};
min-width: 100%;
overflow: hidden;
position: relative;
diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsx
index 24ae045559..d3b9fcc9b2 100644
--- a/web/apps/photos/src/components/FileListWithViewer.tsx
+++ b/web/apps/photos/src/components/FileListWithViewer.tsx
@@ -97,6 +97,7 @@ export type FileListWithViewerProps = {
FileListProps,
| "mode"
| "modePlus"
+ | "layout"
| "header"
| "footer"
| "disableGrouping"
@@ -146,6 +147,7 @@ export type FileListWithViewerProps = {
export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
mode,
modePlus,
+ layout,
header,
footer,
user,
@@ -348,6 +350,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
{...{
mode,
modePlus,
+ layout,
header: headerWithMap,
footer,
user,
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index baeb0bd737..e55f87c8cf 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -106,6 +106,7 @@ import {
createQuickLinkCollection,
removeFromCollection,
removeFromFavoritesCollection,
+ updateCollectionLayout,
} from "ente-new/photos/services/collection";
import {
haveOnlySystemCollections,
@@ -981,6 +982,10 @@ const Page: React.FC = () => {
quickLinkCollection,
ownedSelectedFiles,
);
+ await updateCollectionLayout(
+ quickLinkCollection,
+ "masonry",
+ );
const publicURL = await createPublicURL(
quickLinkCollection.id,
{ enableJoin: false },
@@ -1314,6 +1319,7 @@ const Page: React.FC = () => {
quickLinkNameForFiles([file]),
);
await addToCollection(quickLinkCollection, [file]);
+ await updateCollectionLayout(quickLinkCollection, "masonry");
const publicURL = await createPublicURL(
quickLinkCollection.id,
{ enableJoin: false },
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsx
index 94d2f5ac87..ad270047c0 100644
--- a/web/apps/photos/src/pages/shared-albums.tsx
+++ b/web/apps/photos/src/pages/shared-albums.tsx
@@ -548,7 +548,13 @@ export default function PublicCollectionGallery() {
} else if (errorMessage) {
return (
<Stack100vhCenter>
- <Typography sx={{ color: "critical.main" }}>
+ <Typography
+ sx={{
+ color: "critical.main",
+ px: { xs: 2, sm: 0 },
+ textAlign: { xs: "center", sm: "inherit" },
+ }}
+ >
{errorMessage}
</Typography>
</Stack100vhCenter>
@@ -582,16 +588,15 @@ export default function PublicCollectionGallery() {
);
}
- const layout = publicCollection?.pubMagicMetadata?.data.layout || "grouped";
+ const layout = normalizedPublicAlbumLayout(
+ publicCollection?.pubMagicMetadata?.data.layout,
+ );
const quickLinkDateRange = quickLinkDateRangeForFiles(publicFiles);
const isQuickLinkAlbum =
quickLinkDateRange !== undefined &&
publicCollection?.name === quickLinkDateRange;
const isSingleFileAlbum = publicFiles.length === 1;
- const shouldShowSingleFileViewer =
- isQuickLinkAlbum &&
- isSingleFileAlbum &&
- (layout === "grouped" || layout === "continuous");
+ const shouldShowSingleFileViewer = isQuickLinkAlbum && isSingleFileAlbum;
if (shouldShowSingleFileViewer) {
return (
@@ -688,6 +693,7 @@ export default function PublicCollectionGallery() {
</NavbarBase>
<FileListWithViewer
files={publicFiles}
+ layout={layout === "masonry" ? "masonry" : "grid"}
header={fileListHeader}
footer={fileListFooter}
enableDownload={downloadEnabled}
@@ -695,7 +701,7 @@ export default function PublicCollectionGallery() {
selected={selected}
setSelected={setSelected}
activeCollectionID={PseudoCollectionID.all}
- disableGrouping={layout === "continuous"}
+ disableGrouping={false}
onRemotePull={publicAlbumsRemotePull}
onVisualFeedback={handleVisualFeedback}
onAddSaveGroup={onAddSaveGroup}
@@ -753,6 +759,13 @@ export default function PublicCollectionGallery() {
const sortFilesForCollection = (files: EnteFile[], collection?: Collection) =>
sortFiles(files, collection?.pubMagicMetadata?.data.asc ?? false);
+const normalizedPublicAlbumLayout = (layout: string | undefined) => {
+ if (layout === "grouped" || layout === "trip" || layout === "masonry") {
+ return layout;
+ }
+ return "masonry";
+};
+
const EnteLogoLink = styled("a")(({ theme }) => ({
// Remove the excess space at the top.
svg: { verticalAlign: "middle" },
diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.json
index 8560129d48..ccfe46b2ad 100644
--- a/web/packages/base/locales/en-US/translation.json
+++ b/web/packages/base/locales/en-US/translation.json
@@ -500,7 +500,7 @@
"link_expired": "Link expired",
"link_expired_message": "This link has either expired or has been disabled",
"manage_link": "Manage link",
- "link_request_limit_exceeded": "This album has been viewed on too many devices",
+ "link_request_limit_exceeded": "You have exceeded the maximum number of devices that can view this link. Please contact the album owner.",
"allow_downloads": "Allow downloads",
"allow_adding_photos": "Allow adding photos",
"allow_adding_photos_hint": "Allow people with the link to also add photos to the shared album.",
@@ -809,6 +809,7 @@
"custom_domains_help": "For more information, see <a>help</a>",
"num_1": "1",
"num_2": "2",
+ "masonry": "Masonry",
"grouped": "Grouped",
"continuous": "Continuous",
"trip": "Trip",
diff --git a/web/packages/media/collection.ts b/web/packages/media/collection.ts
index 0d2cff553f..d3cc500ae1 100644
--- a/web/packages/media/collection.ts
+++ b/web/packages/media/collection.ts
@@ -687,9 +687,7 @@ export interface CollectionPublicMagicMetadataData {
/**
* The layout type for the public collection display.
*
- * Expected to be one of: "grouped", "continuous", "trip".
- *
- * When undefined, the UI defaults to "grouped" behavior.
+ * Expected to be one of: "masonry", "grouped", "continuous", "trip".
*/
layout?: string;
}
diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.ts
index ed15cdf6f7..a353743a6b 100644
--- a/web/packages/new/photos/services/collection.ts
+++ b/web/packages/new/photos/services/collection.ts
@@ -1115,7 +1115,7 @@ export const updateCollectionSortOrder = async (
*
* @param collection The collection whose layout we want to change.
*
- * @param layout The layout type ("grouped", "continuous", "trip").
+ * @param layout The layout type ("masonry", "grouped", "continuous", "trip").
*/
export const updateCollectionLayout = async (
collection: Collection,