Skip to content

armgit / ente

Public Imported from GitHub
0

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

refractor(memories):added-comments

Aswin Asok4fc651e0313b
diff --git a/web/apps/memories/src/components/LaneMemoryViewer.tsx b/web/apps/memories/src/components/LaneMemoryViewer.tsx
index 0d144dcd64..ff37c588b8 100644
--- a/web/apps/memories/src/components/LaneMemoryViewer.tsx
+++ b/web/apps/memories/src/components/LaneMemoryViewer.tsx
@@ -1,3 +1,9 @@
+/**
+ * Lane-style public memory viewer.
+ * This file contains the stacked-card lane experience, including lane-specific
+ * playback timing, scrubbing, captions, and decorative backgrounds. It is
+ * rendered by `pages/index.tsx` for the `"lane"` variant.
+ */
import { styled, Typography } from "@mui/material";
import { FileType } from "ente-media/file-type";
import {
@@ -62,6 +68,10 @@ const LANE_GRID_LINE_COLOR = "#08c225";
const LANE_GRID_LINE_OPACITY = 0.06;
const LANE_GRID_DISPLACEMENT_SCALE = 9;
+/**
+ * Primary viewer for lane-style public memory shares.
+ * Used by `pages/index.tsx` when `viewerVariant` resolves to `"lane"`.
+ */
export function LaneMemoryViewer({
files,
currentIndex,
@@ -866,6 +876,10 @@ const LaneDesktopBackgroundGrid = styled("svg")({
"radial-gradient(ellipse 82% 84% at 50% 56%, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.74) 44%, rgba(0, 0, 0, 0.32) 72%, transparent 100%)",
});
+/**
+ * Shared SVG pattern definition for the lane background grids.
+ * Used by both desktop and mobile lane background overlays in this file.
+ */
function LaneBackgroundGridFill({
patternId,
filterId,
@@ -929,6 +943,10 @@ function LaneBackgroundGridFill({
);
}
+/**
+ * Desktop lane background grid overlay.
+ * Used by `LaneBackground` for the non-compact layout branch.
+ */
function LaneDesktopBackgroundGridOverlay() {
return (
<LaneDesktopBackgroundGrid aria-hidden preserveAspectRatio="none">
@@ -978,6 +996,10 @@ const LaneMobileBackgroundGrid = styled("svg")({
"linear-gradient(180deg, rgba(0, 0, 0, 0.96) 0%, rgba(0, 0, 0, 0.78) 10%, rgba(0, 0, 0, 0.42) 24%, rgba(0, 0, 0, 0.30) 52%, rgba(0, 0, 0, 0.52) 76%, rgba(0, 0, 0, 0.92) 100%)",
});
+/**
+ * Mobile lane background grid overlay.
+ * Used by `LaneBackground` for the compact layout branch.
+ */
function LaneMobileBackgroundGridOverlay() {
return (
<LaneMobileBackgroundGrid aria-hidden preserveAspectRatio="none">
@@ -989,6 +1011,10 @@ function LaneMobileBackgroundGridOverlay() {
);
}
+/**
+ * Chooses the correct decorative background for the lane viewer.
+ * Used only by `LaneMemoryViewer`.
+ */
function LaneBackground({
isCompactLayout = false,
}: {
diff --git a/web/apps/memories/src/components/MemoryViewer.tsx b/web/apps/memories/src/components/MemoryViewer.tsx
index dea1f0567f..9bcb4ec3b3 100644
--- a/web/apps/memories/src/components/MemoryViewer.tsx
+++ b/web/apps/memories/src/components/MemoryViewer.tsx
@@ -1,3 +1,10 @@
+/**
+ * Share-style public memory viewer.
+ * This file contains the full-screen viewer used for standard public memory
+ * shares, including header progress, media transitions, playback controls, and
+ * share-specific layout. It is rendered by `pages/index.tsx` for the `"share"`
+ * variant.
+ */
import { keyframes } from "@emotion/react";
import { styled, Typography } from "@mui/material";
import { downloadManager } from "ente-gallery/services/download";
@@ -54,6 +61,10 @@ interface SharedMemoryHeaderProps {
isVideo: boolean;
}
+/**
+ * Share-viewer header with the memory title and segmented autoplay progress.
+ * Used only by `MemoryViewer` for its desktop and mobile layouts.
+ */
function SharedMemoryHeader({
title,
total,
@@ -79,6 +90,10 @@ function SharedMemoryHeader({
);
}
+/**
+ * Primary viewer for normal public memory shares.
+ * Used by `pages/index.tsx` when `viewerVariant` resolves to `"share"`.
+ */
export function MemoryViewer({
files,
currentIndex,
diff --git a/web/apps/memories/src/components/PublicMemoryControls.tsx b/web/apps/memories/src/components/PublicMemoryControls.tsx
index 4447f05744..f645138f49 100644
--- a/web/apps/memories/src/components/PublicMemoryControls.tsx
+++ b/web/apps/memories/src/components/PublicMemoryControls.tsx
@@ -1,3 +1,9 @@
+/**
+ * Shared playback and progress controls for the public memories viewers.
+ * This file contains the share viewer progress bar plus the lane-specific
+ * caption, glyph, and scrubber controls used by `MemoryViewer` and
+ * `LaneMemoryViewer`.
+ */
import { keyframes } from "@emotion/react";
import { Box, styled } from "@mui/material";
import { useCallback, useMemo, useState } from "react";
@@ -68,6 +74,10 @@ const LaneProgressThumb = styled("div")({
transform: "translate(-50%, -50%)",
});
+/**
+ * Play/pause glyph used by the share viewer's playback button.
+ * Used by `MemoryViewer`.
+ */
export const PlaybackGlyph: React.FC<{ paused: boolean }> = ({ paused }) => {
if (paused) {
return (
@@ -106,6 +116,10 @@ export const PlaybackGlyph: React.FC<{ paused: boolean }> = ({ paused }) => {
);
};
+/**
+ * Smaller play/pause glyph sized for the lane viewer footer controls.
+ * Used by `LaneMemoryViewer`.
+ */
export const LanePlaybackGlyph: React.FC<{ paused: boolean }> = ({
paused,
}) => {
@@ -146,6 +160,10 @@ export const LanePlaybackGlyph: React.FC<{ paused: boolean }> = ({
);
};
+/**
+ * Formats and renders the lane caption text, including the animated numeric counter state.
+ * Used by `LaneMemoryViewer`.
+ */
export const LaneCaptionText: React.FC<{
model: LaneCaptionModel;
previousValue?: number;
@@ -191,6 +209,10 @@ interface LaneProgressSliderProps {
onScrubEnd?: (value: number) => void;
}
+/**
+ * Scrubbable progress control for lane shares.
+ * Used by `LaneMemoryViewer`.
+ */
export const LaneProgressSlider: React.FC<LaneProgressSliderProps> = ({
total,
current,
@@ -292,6 +314,10 @@ interface ProgressIndicatorProps {
minimal?: boolean;
}
+/**
+ * Segmented autoplay progress bar for the share viewer header.
+ * Used by `MemoryViewer`.
+ */
export const ProgressIndicator: React.FC<ProgressIndicatorProps> = ({
total,
current,
@@ -365,6 +391,10 @@ interface ProgressBarProps {
onComplete?: () => void;
}
+/**
+ * Single progress segment used to build `ProgressIndicator`.
+ * Used only within `PublicMemoryControls.tsx`.
+ */
const ProgressBar: React.FC<ProgressBarProps> = ({
state,
paused,
diff --git a/web/apps/memories/src/components/PublicMemoryMedia.tsx b/web/apps/memories/src/components/PublicMemoryMedia.tsx
index a377ec631e..8b18375c2d 100644
--- a/web/apps/memories/src/components/PublicMemoryMedia.tsx
+++ b/web/apps/memories/src/components/PublicMemoryMedia.tsx
@@ -1,3 +1,8 @@
+/**
+ * Shared media primitives for the public memories viewers.
+ * This file contains the image and video renderers, loading overlay, and media
+ * sizing/crop helpers used by both `MemoryViewer` and `LaneMemoryViewer`.
+ */
import { Box, CircularProgress, Typography } from "@mui/material";
import log from "ente-base/log";
import {
@@ -54,6 +59,10 @@ const buildMediaStyle = ({
};
};
+/**
+ * Shared loading mask for public memory media while the image or video source is resolving.
+ * Used internally by `PhotoImage` and `VideoPlayer` in this file.
+ */
function MediaLoadingOverlay() {
return (
<Box
@@ -85,6 +94,10 @@ export interface PhotoImageProps {
showLoadingOverlay?: boolean;
}
+/**
+ * Public-memory image renderer that handles thumbnail-to-full-image loading and lane crops.
+ * Used by `MemoryViewer` for share items and by `LaneMemoryViewer` for lane cards.
+ */
export function PhotoImage({
file,
onFullLoad,
@@ -268,6 +281,10 @@ export interface VideoPlayerProps {
showLoadingOverlay?: boolean;
}
+/**
+ * Public-memory video renderer that supports HLS playback, local video fallbacks, and lane crops.
+ * Used by `MemoryViewer` for share playback and by `LaneMemoryViewer` for the active lane card.
+ */
export function VideoPlayer({
file,
onReady,
diff --git a/web/apps/memories/src/components/PublicMemoryPageShell.tsx b/web/apps/memories/src/components/PublicMemoryPageShell.tsx
index f22b60f0c8..a1d294919f 100644
--- a/web/apps/memories/src/components/PublicMemoryPageShell.tsx
+++ b/web/apps/memories/src/components/PublicMemoryPageShell.tsx
@@ -1,9 +1,18 @@
+/**
+ * Shared page shell and top-level fallback states for the public memories flow.
+ * This file defines the document head wrapper plus the loading, error, and
+ * empty states used by `pages/index.tsx` before a viewer is rendered.
+ */
import { CircularProgress, Typography } from "@mui/material";
import { Stack100vhCenter } from "ente-base/components/containers";
import { CustomHead } from "ente-base/components/Head";
import Head from "next/head";
import type { PropsWithChildren } from "react";
+/**
+ * Injects shared metadata for every public memory page.
+ * Used only by `PublicMemoryPageShell` in this file.
+ */
function PublicMemoryDocumentHead() {
return (
<>
@@ -15,6 +24,10 @@ function PublicMemoryDocumentHead() {
);
}
+/**
+ * Wraps every public memory screen with the shared head metadata.
+ * Used by `pages/index.tsx` and by the loading/error/empty state helpers below.
+ */
export function PublicMemoryPageShell({ children }: PropsWithChildren) {
return (
<>
@@ -24,6 +37,10 @@ export function PublicMemoryPageShell({ children }: PropsWithChildren) {
);
}
+/**
+ * Full-screen loading state shown while `usePublicMemoryPage` is resolving the share.
+ * Used by `pages/index.tsx`.
+ */
export function PublicMemoryLoadingState() {
return (
<PublicMemoryPageShell>
@@ -34,6 +51,10 @@ export function PublicMemoryLoadingState() {
);
}
+/**
+ * Full-screen error state for invalid, expired, or failed public memory loads.
+ * Used by `pages/index.tsx`.
+ */
export function PublicMemoryErrorState({ message }: { message: string }) {
return (
<PublicMemoryPageShell>
@@ -46,6 +67,10 @@ export function PublicMemoryErrorState({ message }: { message: string }) {
);
}
+/**
+ * Full-screen empty state for shares that resolve without any files.
+ * Used by `pages/index.tsx`.
+ */
export function PublicMemoryEmptyState() {
return (
<PublicMemoryPageShell>
diff --git a/web/apps/memories/src/components/PublicMemoryViewerShared.ts b/web/apps/memories/src/components/PublicMemoryViewerShared.ts
index 336dfd31eb..2b15a70e81 100644
--- a/web/apps/memories/src/components/PublicMemoryViewerShared.ts
+++ b/web/apps/memories/src/components/PublicMemoryViewerShared.ts
@@ -1,3 +1,9 @@
+/**
+ * Shared types, constants, helpers, and reusable styled primitives for the
+ * public memories viewers. This file supports both `MemoryViewer` and
+ * `LaneMemoryViewer`, and is also imported by `pages/index.tsx` for viewer prop
+ * types.
+ */
import { styled } from "@mui/material";
import type { EnteFile } from "ente-media/file";
import type {
@@ -46,6 +52,7 @@ export function isInteractiveTapTarget(target: EventTarget | null) {
);
}
+// Shared fullscreen root used by both `MemoryViewer` and `LaneMemoryViewer`.
export const ViewerRoot = styled("div")({
position: "relative",
width: "100vw",
@@ -62,6 +69,7 @@ export const ViewerRoot = styled("div")({
touchAction: "manipulation",
});
+// Shared branded anchor used in the footer and header CTA areas of both viewers.
export const BrandLink = styled("a")({
color: "inherit",
textDecoration: "none",
@@ -71,6 +79,7 @@ export const BrandLink = styled("a")({
flexShrink: 0,
});
+// Shared Ente wordmark image used inside `BrandLink` in both viewers.
export const EnteBrandTagImage = styled("img")({
width: "76px",
height: "auto",
@@ -78,6 +87,7 @@ export const EnteBrandTagImage = styled("img")({
userSelect: "none",
});
+// Desktop-sized CTA used by both `MemoryViewer` and `LaneMemoryViewer`.
export const JoinNowButton = styled("a")({
backgroundColor: "#08c225",
color: "white",
@@ -93,6 +103,7 @@ export const JoinNowButton = styled("a")({
"@media (max-width: 900px)": { padding: "14px 24px", fontSize: "14px" },
});
+// Mobile CTA used by both viewer variants when actions collapse into the footer.
export const MobileJoinNowButton = styled("a")({
backgroundColor: "#08c225",
color: "white",
@@ -105,6 +116,7 @@ export const MobileJoinNowButton = styled("a")({
whiteSpace: "nowrap",
});
+// Shared mobile footer action row used by both viewers.
export const ViewerFooterBar = styled("div")({
width: "100%",
display: "flex",
@@ -115,6 +127,7 @@ export const ViewerFooterBar = styled("div")({
paddingBottom: "max(2px, env(safe-area-inset-bottom, 0px))",
});
+// Shared gesture-aware media container used by both viewers around the active media.
export const PhotoContainer = styled("div")({
position: "relative",
display: "flex",