π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
refactor(photos):add-gallery-navigation-actions-context
Aswin Asokea7bfd4ea26f
diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsxindex ab387f6d75..1f91bff9c4 100644--- a/web/apps/photos/src/components/FileListWithViewer.tsx+++ b/web/apps/photos/src/components/FileListWithViewer.tsx@@ -1,4 +1,5 @@import type { RemotePullOpts } from "@/components/gallery";+import { usePhotosNavigation } from "@/components/gallery/PhotosNavigationContext";import { downloadAndSaveFiles } from "@/services/save";import { uploadManager } from "@/services/upload-manager";import { fileTimelineDateString } from "@/utils/file";@@ -84,8 +85,6 @@ export type FileListWithViewerProps = {| "onToggleFavorite"| "onFileVisibilityUpdate"| "onSendLink"- | "onSelectCollection"- | "onSelectPerson">;export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({@@ -131,8 +130,6 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({onFileVisibilityUpdate,onSendLink,onMarkTempDeleted,- onSelectCollection,- onSelectPerson,onAddFileToCollection,onScroll,onVisibleDateChange,@@ -141,6 +138,10 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({pendingHighlightCommentID,onPendingNavigationConsumed,}) => {+ const {+ selectCollectionFromViewer: onSelectCollection,+ selectPerson: onSelectPerson,+ } = usePhotosNavigation();const [openFileViewer, setOpenFileViewer] = useState(false);const [currentIndex, setCurrentIndex] = useState(0);const [initialSidebar, setInitialSidebar] = useState<diff --git a/web/apps/photos/src/components/SearchBar.tsx b/web/apps/photos/src/components/SearchBar.tsxindex 085d732bdf..663fbf13a0 100644--- a/web/apps/photos/src/components/SearchBar.tsx+++ b/web/apps/photos/src/components/SearchBar.tsx@@ -1,3 +1,4 @@+import { usePhotosNavigation } from "@/components/gallery/PhotosNavigationContext";import { sidebarTheme } from "@/components/sidebar/theme";import {groupSearchOptions,@@ -66,15 +67,10 @@ import AsyncSelect from "react-select/async";export interface SearchBarProps {isInSearchMode: boolean;isSettingsOpen: boolean;- onSelectSearchOption: (- o: SearchOption | undefined,- options?: { shouldExitSearchMode?: boolean },- ) => void;- onSelectPeople: (onNavigate: () => void) => void;- onSelectPerson: (personID: string) => void;}export const SearchBar: React.FC<SearchBarProps> = (props) => {+ const { selectSearchOption } = usePhotosNavigation();const isSmallWidth = useIsSmallWidth();const [open, setOpen] = useState(false);const [searchResetKey, setSearchResetKey] = useState(0);@@ -95,7 +91,7 @@ export const SearchBar: React.FC<SearchBarProps> = (props) => {const showSearch = () => setOpen(true);const closeSearch = () => setOpen(false);const clearSearch = () => {- props.onSelectSearchOption(undefined, { shouldExitSearchMode: true });+ selectSearchOption(undefined, { shouldExitSearchMode: true });setOpen(false);};@@ -196,13 +192,12 @@ export const SearchBar: React.FC<SearchBarProps> = (props) => {const SearchInput: React.FC<SearchBarProps & { open: boolean; onClose: () => void }-> = ({- onSelectSearchOption,- onSelectPeople,- onSelectPerson,- open,- onClose,-}) => {+> = ({ open, onClose }) => {+ const {+ selectSearchOption: onSelectSearchOption,+ showPeople: onSelectPeople,+ selectPerson: onSelectPerson,+ } = usePhotosNavigation();const selectRef = useRef<SelectInstance<SearchOption> | null>(null);// undefined makes react-select switch from controlled to uncontrolled.const [value, setValue] = useState<SearchOption | null>(null);@@ -699,9 +694,10 @@ const Input: React.FC<InputProps<SearchOption, false>> = (props) => (/>);-const EmptyState: React.FC<- Pick<SearchBarProps, "onSelectPerson"> & { onSelectPeople: () => void }-> = ({ onSelectPeople, onSelectPerson }) => {+const EmptyState: React.FC<{+ onSelectPerson: (personID: string) => void;+ onSelectPeople: () => void;+}> = ({ onSelectPeople, onSelectPerson }) => {const mlStatus = useMLStatusSnapshot();const people = usePeopleStateSnapshot()?.visiblePeople;const vpStatus = useHLSGenerationStatusSnapshot();diff --git a/web/apps/photos/src/components/collections/CollectionHeader.tsx b/web/apps/photos/src/components/collections/CollectionHeader.tsxindex 0c6f00b766..7ac3026fee 100644--- a/web/apps/photos/src/components/collections/CollectionHeader.tsx+++ b/web/apps/photos/src/components/collections/CollectionHeader.tsx@@ -1,4 +1,5 @@import type { RemotePullOpts } from "@/components/gallery";+import { usePhotosNavigation } from "@/components/gallery/PhotosNavigationContext";import { downloadAndSaveCollectionFiles } from "@/services/save";import {CleanIcon,@@ -87,7 +88,6 @@ import { Trans } from "react-i18next";export interface CollectionHeaderProps {collectionSummary: CollectionSummary;activeCollection: Collection | undefined;- setActiveCollectionID: (collectionID: number) => void;isActiveCollectionDownloadInProgress: () => boolean;onRemotePull: (opts?: RemotePullOpts) => Promise<void>;onCollectionShare: () => void;@@ -97,17 +97,15 @@ export interface CollectionHeaderProps {onEditAlbumDetails: () => void;hasActiveFileSelection: boolean;onAddSaveGroup: AddSaveGroup;- onShowMap: () => void;- onBackToAlbums: () => void;showBackToAlbums: boolean;onDescriptionHeightChange?: (height: number) => void;}export const CollectionHeader: React.FC<CollectionHeaderProps> = (props) => {+ const { backToAlbums } = usePhotosNavigation();const {activeCollection,collectionSummary,- onBackToAlbums,showBackToAlbums,onDescriptionHeightChange,} = props;@@ -168,7 +166,7 @@ export const CollectionHeader: React.FC<CollectionHeaderProps> = (props) => {<Tooltip title={t("go_back")}><IconButtonaria-label={t("go_back")}- onClick={onBackToAlbums}+ onClick={backToAlbums}sx={{ width: 32, height: 32, flexShrink: 0 }}><ArrowBackIcon sx={{ fontSize: 20 }} />@@ -234,7 +232,6 @@ const shouldShowOptions = (type: CollectionSummaryType) =>const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({activeCollection,collectionSummary,- setActiveCollectionID,onRemotePull,onCollectionShare,onCollectionManageLink,@@ -244,8 +241,11 @@ const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({hasActiveFileSelection,onAddSaveGroup,isActiveCollectionDownloadInProgress,- onShowMap,}) => {+ const {+ selectCollection: setActiveCollectionID,+ showCollectionMap: onShowMap,+ } = usePhotosNavigation();const { showMiniDialog, onGenericError } = useBaseContext();const { showLoadingBar, hideLoadingBar, showNotification } =usePhotosAppContext();diff --git a/web/apps/photos/src/components/collections/CollectionMap.tsx b/web/apps/photos/src/components/collections/CollectionMap.tsxindex dd65a3c60f..6e7a0a838b 100644--- a/web/apps/photos/src/components/collections/CollectionMap.tsx+++ b/web/apps/photos/src/components/collections/CollectionMap.tsx@@ -69,8 +69,6 @@ interface CollectionMapProps extends Pick<| "onVisualFeedback"| "fileNormalCollectionIDs"| "collectionNameByID"- | "onSelectCollection"- | "onSelectPerson"| "emailByUserID"> {selectedPlace?: PlaceSelection;@@ -1007,8 +1005,6 @@ export const CollectionMap: React.FC<CollectionMapProps> = ({onVisualFeedback,fileNormalCollectionIDs,collectionNameByID,- onSelectCollection,- onSelectPerson,mapFileSource,emailByUserID,}) => {@@ -1165,8 +1161,6 @@ export const CollectionMap: React.FC<CollectionMapProps> = ({onRemoteFilesPull={onRemoteFilesPull}fileNormalCollectionIDs={fileNormalCollectionIDs}collectionNameByID={collectionNameByID}- onSelectCollection={onSelectCollection}- onSelectPerson={onSelectPerson}emailByUserID={emailByUserID}/><Box sx={{ width: "100%", height: "100%" }}>@@ -1218,8 +1212,6 @@ interface CollectionSidebarProps {onRemoteFilesPull?: FileListWithViewerProps["onRemoteFilesPull"];fileNormalCollectionIDs?: FileListWithViewerProps["fileNormalCollectionIDs"];collectionNameByID?: FileListWithViewerProps["collectionNameByID"];- onSelectCollection?: FileListWithViewerProps["onSelectCollection"];- onSelectPerson?: FileListWithViewerProps["onSelectPerson"];emailByUserID: FileListWithViewerProps["emailByUserID"];}@@ -1243,8 +1235,6 @@ function CollectionSidebar({onRemoteFilesPull,fileNormalCollectionIDs,collectionNameByID,- onSelectCollection,- onSelectPerson,emailByUserID,}: CollectionSidebarProps) {const emptySelected = useMemo<SelectedState>(@@ -1318,8 +1308,6 @@ function CollectionSidebar({onRemoteFilesPull={onRemoteFilesPull}fileNormalCollectionIDs={fileNormalCollectionIDs}collectionNameByID={collectionNameByID}- onSelectCollection={onSelectCollection}- onSelectPerson={onSelectPerson}emailByUserID={emailByUserID}enableImageEditing={false}enableDownload={true}diff --git a/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsxindex 0404caf94f..b9c61bb3f2 100644--- a/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsx+++ b/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsx@@ -39,9 +39,6 @@ type GalleryBarAndListHeaderProps = {activeCollection: Collection | undefined;activePerson: Person | undefined;people: Person[];- setActiveCollectionID: (collectionID: number) => void;- onSelectPerson: (personID: string) => void;- onBackToPeople: () => void;setFileListHeader: (header: FileListHeaderOrFooter) => void;hasActiveFileSelection: boolean;} & Pick<@@ -50,9 +47,7 @@ type GalleryBarAndListHeaderProps = {| "onRemotePull"| "onAddSaveGroup"| "onEditAlbumDetails"- | "onShowMap"| "onCollectionSlideshow"- | "onBackToAlbums"| "showBackToAlbums"> &Pick<@@ -69,10 +64,8 @@ export const GalleryBarAndListHeader: React.FC<collectionSummary,albums,activeCollection,- setActiveCollectionID,setBlockingLoad,people,- onSelectPerson,isActiveCollectionDownloadInProgress,hasActiveFileSelection,activePerson,@@ -81,12 +74,9 @@ export const GalleryBarAndListHeader: React.FC<onRemotePull,onEditAlbumDetails,onAddSaveGroup,- onShowMap,onCollectionSlideshow,setFileListHeader,- onBackToAlbums,showBackToAlbums,- onBackToPeople,}) => {const { show: showCollectionShare, props: collectionShareVisibilityProps } =useModalVisibility();@@ -139,20 +129,15 @@ export const GalleryBarAndListHeader: React.FC<: "section_archive",)}albums={albums}- onSelectAlbum={setActiveCollectionID}- onBack={onBackToAlbums}/>)}<CollectionHeader{...{activeCollection,- setActiveCollectionID,isActiveCollectionDownloadInProgress,onRemotePull,onAddSaveGroup,- onShowMap,onCollectionSlideshow,- onBackToAlbums,showBackToAlbums,}}collectionSummary={collectionSummary}@@ -172,12 +157,7 @@ export const GalleryBarAndListHeader: React.FC</></GalleryItemsHeaderAdapter>) : activePerson ? (- <PeopleHeader- onBack={onBackToPeople}- person={activePerson}- people={people}- onSelectPerson={onSelectPerson}- />+ <PeopleHeader person={activePerson} people={people} />) : (<></>),@@ -202,11 +182,8 @@ export const GalleryBarAndListHeader: React.FC<hasActiveFileSelection,onRemotePull,onAddSaveGroup,- onShowMap,onCollectionSlideshow,- onBackToAlbums,showBackToAlbums,- onBackToPeople,onEditAlbumDetails,albumDescription,descriptionHeight,diff --git a/web/apps/photos/src/components/gallery/AlbumsHeader.tsx b/web/apps/photos/src/components/gallery/AlbumsHeader.tsxindex 0b4676be43..5c51b59c97 100644--- a/web/apps/photos/src/components/gallery/AlbumsHeader.tsx+++ b/web/apps/photos/src/components/gallery/AlbumsHeader.tsx@@ -6,22 +6,17 @@ import { useState } from "react";import AutoSizer from "react-virtualized-auto-sizer";import { FixedSizeList, type ListChildComponentProps } from "react-window";import { AlbumTile } from "./AlbumTile";+import { usePhotosNavigation } from "./PhotosNavigationContext";interface AlbumsHeaderProps {title: string;albums: CollectionSummary[];- onSelectAlbum: (id: number) => void;- onBack: () => void;}export const albumsHeaderHeight = 311;-export const AlbumsHeader = ({- title,- albums,- onSelectAlbum,- onBack,-}: AlbumsHeaderProps) => {+export const AlbumsHeader = ({ title, albums }: AlbumsHeaderProps) => {+ const { backToAlbums } = usePhotosNavigation();const [scrollOffset, setScrollOffset] = useState(0);return (@@ -38,7 +33,7 @@ export const AlbumsHeader = ({<Tooltip title={t("go_back")}><IconButtonaria-label={t("go_back")}- onClick={onBack}+ onClick={backToAlbums}sx={{ width: 32, height: 32 }}><ArrowBackIcon sx={{ fontSize: 20 }} />@@ -74,7 +69,7 @@ export const AlbumsHeader = ({height={200}itemCount={albums.length}itemSize={162}- itemData={{ albums, onSelectAlbum }}+ itemData={{ albums }}itemKey={(index, data) =>data.albums[index]!.id}@@ -107,17 +102,16 @@ export const AlbumsHeader = ({const HeaderAlbumTile = ({index,style,- data: { albums, onSelectAlbum },+ data: { albums },isScrolling,-}: ListChildComponentProps<- Pick<AlbumsHeaderProps, "albums" | "onSelectAlbum">->) => {+}: ListChildComponentProps<Pick<AlbumsHeaderProps, "albums">>) => {+ const { selectCollection } = usePhotosNavigation();const album = albums[index]!;return (<div style={style}><AlbumTilealbum={album}- onSelectAlbum={onSelectAlbum}+ onSelectAlbum={selectCollection}isScrolling={isScrolling}showBadges={false}countLabel={t("photos_count", { count: album.fileCount })}diff --git a/web/apps/photos/src/components/gallery/AlbumsOverview.tsx b/web/apps/photos/src/components/gallery/AlbumsOverview.tsxindex 8b6f6f800c..c0ccfcb027 100644--- a/web/apps/photos/src/components/gallery/AlbumsOverview.tsx+++ b/web/apps/photos/src/components/gallery/AlbumsOverview.tsx@@ -25,6 +25,7 @@ import {AlbumTile,AlbumTileCover as Cover,} from "./AlbumTile";+import { usePhotosNavigation } from "./PhotosNavigationContext";interface AlbumsOverviewProps {albums: CollectionSummary[];@@ -32,7 +33,6 @@ interface AlbumsOverviewProps {filter: AlbumFilter | "links";searchQuery: string;sortBy: CollectionsSortBy;- onSelectAlbum: (id: number) => void;onCreateAlbum: () => void;onRemotePull: (opts?: RemotePullOpts) => Promise<void>;}@@ -43,10 +43,12 @@ export const AlbumsOverview = ({filter,searchQuery,sortBy,- onSelectAlbum,onCreateAlbum,onRemotePull,}: AlbumsOverviewProps) => {+ const { selectCollection, openOverviewAlbum } = usePhotosNavigation();+ const onSelectAlbum =+ filter == "links" ? selectCollection : openOverviewAlbum;const compact = useMediaQuery(useTheme().breakpoints.down("md"));const listRef = useRef<FixedSizeList>(null);const [listElement, setListElement] = useState<HTMLDivElement | null>(null);diff --git a/web/apps/photos/src/components/gallery/BarImpl.tsx b/web/apps/photos/src/components/gallery/BarImpl.tsxindex a34a8abe03..88afd0a735 100644--- a/web/apps/photos/src/components/gallery/BarImpl.tsx+++ b/web/apps/photos/src/components/gallery/BarImpl.tsx@@ -46,6 +46,7 @@ import { wait } from "ente-utils/promise";import { t } from "i18next";import React, {memo,+ useCallback,useEffect,useId,useMemo,@@ -59,6 +60,7 @@ import {areEqual,type ListChildComponentProps,} from "react-window";+import { usePhotosNavigation } from "./PhotosNavigationContext";import { PlacesList, type PlaceSelection } from "./PlacesList";import type { GalleryBarMode } from "./reducer";@@ -71,22 +73,13 @@ export interface GalleryBarImplProps extends GalleryBarPresentationProps {mode: GalleryBarMode;placesFiles?: EnteFile[];selectedPlace?: PlaceSelection;- onSelectPlace: (place: PlaceSelection | undefined) => void;albumFilter: AlbumFilter;albumSearchQuery: string;onAlbumSearchQueryChange: (query: string) => void;- onShowAlbumOverview: (filter: AlbumFilter) => void;- onShowPeopleOverview: () => void;- onShowLinksOverview: () => void;collectionSummaries: CollectionSummary[];visibleAlbumFilters: typeof albumFilters;uncategorizedCollectionSummaryID: number;- onShowCollectionSummary: (- collectionSummaryID: number,- isHiddenCollectionSummary?: boolean,- ) => Promise<boolean>;activeCollectionID: number | undefined;- onSelectCollectionID: (collectionID: number) => void;onCreateAlbum: () => void;collectionsSortBy: CollectionsSortBy;onChangeCollectionsSortBy: (by: CollectionsSortBy) => void;@@ -94,26 +87,19 @@ export interface GalleryBarImplProps extends GalleryBarPresentationProps {onChangePeopleSortBy: (by: PeopleSortBy) => void;people: Person[];activePerson: Person | undefined;- onSelectPerson: (personID: string) => void;}export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({mode,placesFiles,selectedPlace,- onSelectPlace,albumFilter,albumSearchQuery,onAlbumSearchQueryChange,- onShowAlbumOverview,- onShowPeopleOverview,- onShowLinksOverview,collectionSummaries,visibleAlbumFilters,uncategorizedCollectionSummaryID,- onShowCollectionSummary,activeCollectionID,- onSelectCollectionID,onCreateAlbum,collectionsSortBy,onChangeCollectionsSortBy,@@ -121,10 +107,40 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({onChangePeopleSortBy,people,activePerson,- onSelectPerson,collapsed,mobileDrawerProps,}) => {+ const {+ selectCollection,+ selectPerson,+ selectPlace,+ showAlbumOverview: onShowAlbumOverview,+ showPeople: onShowPeopleOverview,+ showLinksOverview: onShowLinksOverview,+ showCollectionSummary: onShowCollectionSummary,+ } = usePhotosNavigation();+ const { onClose: closeMobileNavigation } = mobileDrawerProps;+ const onSelectCollectionID = useCallback(+ (id: number) => {+ selectCollection(id);+ closeMobileNavigation();+ },+ [selectCollection, closeMobileNavigation],+ );+ const onSelectPerson = useCallback(+ (id: string) => {+ selectPerson(id);+ closeMobileNavigation();+ },+ [selectPerson, closeMobileNavigation],+ );+ const onSelectPlace = useCallback(+ (place: PlaceSelection | undefined) => {+ selectPlace(place);+ closeMobileNavigation();+ },+ [selectPlace, closeMobileNavigation],+ );const mobile = useMediaQuery(useTheme().breakpoints.down("md"));const titleID = useId();const listRef = useRef<FixedSizeList | null>(null);diff --git a/web/apps/photos/src/components/gallery/GalleryDownloadStatusNotifications.tsx b/web/apps/photos/src/components/gallery/GalleryDownloadStatusNotifications.tsxnew file mode 100644index 0000000000..dac9e15d19--- /dev/null+++ b/web/apps/photos/src/components/gallery/GalleryDownloadStatusNotifications.tsx@@ -0,0 +1,24 @@+import {+ DownloadStatusNotifications,+ type DownloadStatusNotificationsProps,+} from "ente-gallery/components/DownloadStatusNotifications";+import { useCallback } from "react";+import { usePhotosNavigation } from "./PhotosNavigationContext";++export const GalleryDownloadStatusNotifications = (+ props: Omit<DownloadStatusNotificationsProps, "onShowCollectionSummary">,+) => {+ const { showCollectionSummary } = usePhotosNavigation();+ const onShowCollectionSummary = useCallback(+ (id: number | undefined, isHidden: boolean | undefined) => {+ void showCollectionSummary(id, isHidden);+ },+ [showCollectionSummary],+ );+ return (+ <DownloadStatusNotifications+ {...props}+ onShowCollectionSummary={onShowCollectionSummary}+ />+ );+};diff --git a/web/apps/photos/src/components/gallery/PeopleHeader.tsx b/web/apps/photos/src/components/gallery/PeopleHeader.tsxindex 1a80c4951b..d85b64ffec 100644--- a/web/apps/photos/src/components/gallery/PeopleHeader.tsx+++ b/web/apps/photos/src/components/gallery/PeopleHeader.tsx@@ -97,19 +97,18 @@ import type {} from "ente-new/photos/services/ml/people";import { t } from "i18next";import React, { useEffect, useReducer, useState } from "react";-import type { GalleryBarImplProps } from "./BarImpl";+import { usePhotosNavigation } from "./PhotosNavigationContext";-type PeopleHeaderProps = Pick<- GalleryBarImplProps,- "people" | "onSelectPerson"-> & { person: Person; onBack: () => void };+interface PeopleHeaderProps {+ people: Person[];+ person: Person;+}export const PeopleHeader: React.FC<PeopleHeaderProps> = ({people,- onSelectPerson,person,- onBack,}) => {+ const { backToPeople } = usePhotosNavigation();return (<GalleryItemsHeaderAdaptersx={{ display: "flex", alignItems: "center", gap: 2 }}@@ -117,7 +116,7 @@ export const PeopleHeader: React.FC<PeopleHeaderProps> = ({<Tooltip title={t("go_back")}><IconButtonaria-label={t("go_back")}- onClick={onBack}+ onClick={backToPeople}sx={{display: { xs: "none", sm: "inline-flex" },width: 32,@@ -137,10 +136,7 @@ export const PeopleHeader: React.FC<PeopleHeaderProps> = ({<CGroupPersonHeader person={person} />)) : (- <ClusterPersonHeader- person={person}- {...{ people, onSelectPerson }}- />+ <ClusterPersonHeader person={person} people={people} />)}</SpacedRow></GalleryItemsHeaderAdapter>@@ -305,14 +301,12 @@ const IgnoredPersonHeader: React.FC<IgnoredPersonHeaderProps> = ({);};-type ClusterPersonHeaderProps = Pick<- PeopleHeaderProps,- "people" | "onSelectPerson"-> & { person: ClusterPerson };+type ClusterPersonHeaderProps = Pick<PeopleHeaderProps, "people"> & {+ person: ClusterPerson;+};const ClusterPersonHeader: React.FC<ClusterPersonHeaderProps> = ({people,- onSelectPerson,person,}) => {const cluster = person.cluster;@@ -366,24 +360,22 @@ const ClusterPersonHeader: React.FC<ClusterPersonHeaderProps> = ({<AddPersonDialog{...addPersonVisibilityProps}- {...{ people, onSelectPerson, cluster }}+ {...{ people, cluster }}/></>);};type AddPersonDialogProps = ModalVisibilityProps &- Pick<PeopleHeaderProps, "people" | "onSelectPerson"> & {- cluster: FaceCluster;- };+ Pick<PeopleHeaderProps, "people"> & { cluster: FaceCluster };const AddPersonDialog: React.FC<AddPersonDialogProps> = ({open,onClose,people,- onSelectPerson,cluster,}) => {+ const { selectPerson: onSelectPerson } = usePhotosNavigation();const isFullScreen = useMediaQuery(collectionDialogFullScreenQuery);const [openNameInput, setOpenNameInput] = useState(false);diff --git a/web/apps/photos/src/components/gallery/PeopleOverview.tsx b/web/apps/photos/src/components/gallery/PeopleOverview.tsxindex 7a4288169e..7dd17037ec 100644--- a/web/apps/photos/src/components/gallery/PeopleOverview.tsx+++ b/web/apps/photos/src/components/gallery/PeopleOverview.tsx@@ -19,18 +19,18 @@ import { useMemo, useState } from "react";import AutoSizer from "react-virtualized-auto-sizer";import { VariableSizeList, type ListChildComponentProps } from "react-window";import { PeopleEmptyState } from ".";+import { usePhotosNavigation } from "./PhotosNavigationContext";export const PeopleOverview = ({people,allPeople,peopleSortBy,- onSelectPerson,}: {people: Person[];allPeople: Person[];peopleSortBy: PeopleSortBy;- onSelectPerson: (id: string) => void;}) => {+ const { selectPerson: onSelectPerson } = usePhotosNavigation();const mobile = useMediaQuery(useTheme().breakpoints.down("md"));const [showingAllPeople, setShowingAllPeople] = useState(false);const sortedPeople = useMemo(diff --git a/web/apps/photos/src/components/gallery/PhotosNavigationContext.tsx b/web/apps/photos/src/components/gallery/PhotosNavigationContext.tsxnew file mode 100644index 0000000000..99966d3cc8--- /dev/null+++ b/web/apps/photos/src/components/gallery/PhotosNavigationContext.tsx@@ -0,0 +1,48 @@+import type { AlbumFilter } from "@/utils/album-filters";+import type { SearchOption } from "ente-new/photos/services/search/types";+import { createContext, useContext } from "react";+import type { PlaceSelection } from "./PlacesList";+import type { GalleryBarMode } from "./reducer";++export interface PhotosNavigationActions {+ goHome: () => void;+ changeMode: (mode: GalleryBarMode) => boolean;+ showLibraryMap: () => void;+ showCollectionMap: () => void;+ selectPlace: (place: PlaceSelection | undefined) => void;+ showCollectionSummary: (+ id: number | undefined,+ isHidden?: boolean,+ ) => Promise<boolean>;+ selectCollection: (id: number) => void;+ selectCollectionFromViewer: (id: number) => void;+ openOverviewAlbum: (id: number) => void;+ showAlbumOverview: (filter: AlbumFilter) => void;+ backToAlbums: () => void;+ showLinksOverview: () => boolean;+ showPeople: (onNavigate?: () => void) => boolean;+ selectPerson: (id: string) => void;+ backToPeople: () => void;+ selectSearchOption: (+ option: SearchOption | undefined,+ options?: { shouldExitSearchMode?: boolean },+ ) => void;+ showCleanupView: (view: "large-files" | "duplicates") => void;+}++const PhotosNavigationContext = createContext<+ PhotosNavigationActions | undefined+>(undefined);++export const PhotosNavigationProvider = PhotosNavigationContext.Provider;++// eslint-disable-next-line react-refresh/only-export-components+export const usePhotosNavigation = (): PhotosNavigationActions => {+ const actions = useContext(PhotosNavigationContext);+ if (!actions) {+ throw new Error(+ "usePhotosNavigation must be used within PhotosNavigationProvider",+ );+ }+ return actions;+};diff --git a/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx b/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsxindex 497f8b4562..05993ccdb4 100644--- a/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx+++ b/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx@@ -52,26 +52,21 @@ import {type GalleryBarPresentationProps,} from "./BarImpl";import { NavigationSlide } from "./NavigationSlide";+import { usePhotosNavigation } from "./PhotosNavigationContext";import type { GalleryBarMode } from "./reducer";import { useNavigationContentMotion } from "./use-navigation-content-motion";type GalleryNavigation = Omit<GalleryBarImplProps,- | keyof GalleryBarPresentationProps- | "mode"- | "onCreateAlbum"- | "onSelectPerson"+ keyof GalleryBarPresentationProps | "mode" | "onCreateAlbum"> & { onRemotePull: (opts?: RemotePullOpts) => Promise<void> };type PhotosNavigationShellProps = SearchBarProps & {onSidebar: () => void;onUpload: () => void;- onHome: () => void;- onShowMap: () => void;isMapView: boolean;isMapSelected: boolean;mode: GalleryBarMode;- onChangeMode: (mode: GalleryBarMode) => boolean;};export interface PhotosNavigationShellHandle {@@ -86,7 +81,6 @@ export const PhotosNavigationShell: React.FC<alternateHeader: ReactNode;galleryNavigation: GalleryNavigation | undefined;collectionNameByID: Map<number, string>;- onShowCleanupView: (view: "large-files" | "duplicates") => void;onAuthenticateUser: () => Promise<boolean>;}>@@ -96,11 +90,12 @@ export const PhotosNavigationShell: React.FC<alternateHeader,galleryNavigation,collectionNameByID,- onShowCleanupView,onAuthenticateUser,children,...props}) => {+ const { changeMode, showLibraryMap, selectCollection, showCleanupView } =+ usePhotosNavigation();const { show: showSidebar, props: sidebarVisibilityProps } =useModalVisibility();const [pendingSidebarAction, setPendingSidebarAction] =@@ -141,21 +136,12 @@ export const PhotosNavigationShell: React.FC<setNavigationCollapsed((collapsed) => !collapsed);}};- const { onSelectCollectionID } = galleryNavigation ?? {};- const { onSelectPerson } = props;- const selectCollection = useCallback(+ const selectCreatedCollection = useCallback((id: number) => {- onSelectCollectionID?.(id);+ if (galleryNavigation) selectCollection(id);closeMobileNavigation();},- [onSelectCollectionID, closeMobileNavigation],- );- const selectPerson = useCallback(- (id: string) => {- onSelectPerson(id);- closeMobileNavigation();- },- [onSelectPerson, closeMobileNavigation],+ [galleryNavigation, selectCollection, closeMobileNavigation],);const { show: showAlbumNameInput, props: albumNameInputVisibilityProps } =useModalVisibility();@@ -173,7 +159,7 @@ export const PhotosNavigationShell: React.FC<const handleChangeMode = (mode: GalleryBarMode) => {if (mode == "people" && !mobile) {closeMobileNavigation();- props.onChangeMode(mode);+ changeMode(mode);return;}const reopeningSection =@@ -198,7 +184,7 @@ export const PhotosNavigationShell: React.FC<}return;}- if (!props.onChangeMode(mode)) return;+ if (!changeMode(mode)) return;setNavigationCollapsed(false);if (mobile) showMobileNavigation();};@@ -209,12 +195,6 @@ export const PhotosNavigationShell: React.FC<collapsed={!panelOpen}mobileDrawerProps={mobileDrawerProps}onCreateAlbum={openAlbumCreation}- onSelectCollectionID={selectCollection}- onSelectPlace={(place) => {- galleryNavigation.onSelectPlace(place);- closeMobileNavigation();- }}- onSelectPerson={selectPerson}/>);return (@@ -291,7 +271,7 @@ export const PhotosNavigationShell: React.FC<isSettingsOpen={sidebarVisibilityProps.open}onSidebar={() => showSettings()}onShowMap={() => {- props.onShowMap();+ showLibraryMap();setNavigationCollapsed(false);if (mobile) showMobileNavigation();}}@@ -337,7 +317,7 @@ export const PhotosNavigationShell: React.FC<{...albumNameInputVisibilityProps}isHidden={createInHiddenSection}onRemotePull={galleryNavigation.onRemotePull}- onSelectCollectionID={selectCollection}+ onSelectCollectionID={selectCreatedCollection}/></>)}@@ -378,8 +358,8 @@ export const PhotosNavigationShell: React.FC<{...sidebarVisibilityProps}pendingAction={pendingSidebarAction}onActionHandled={handleSidebarActionHandled}- onShowLargeFiles={() => onShowCleanupView("large-files")}- onShowDuplicates={() => onShowCleanupView("duplicates")}+ onShowLargeFiles={() => showCleanupView("large-files")}+ onShowDuplicates={() => showCleanupView("duplicates")}collectionNameByID={collectionNameByID}onAuthenticateUser={onAuthenticateUser}setLoading={setSettingsLoading}@@ -468,18 +448,15 @@ const NormalHeaderContents: React.FC<};const NormalNavigationRail: React.FC<- Omit<- PhotosNavigationShellProps,- "onUpload" | "onChangeMode" | "isMapView"- > & {+ Omit<PhotosNavigationShellProps, "onUpload" | "isMapView"> & {onChangeMode: (mode: GalleryBarMode) => void;+ onShowMap: () => void;isHome: boolean;opensDialog: boolean;navigationOpen: boolean;}> = ({onSidebar,- onHome,onShowMap,isMapSelected,mode,@@ -490,7 +467,7 @@ const NormalNavigationRail: React.FC<...props}) => (<>- <HomeButton onClick={onHome} selected={isHome} />+ <HomeButton selected={isHome} /><SearchBar {...props} /><Boxaria-hidden@@ -605,34 +582,34 @@ const NormalNavigationRail: React.FC<</>);-const HomeButton: React.FC<ButtonishProps & { selected: boolean }> = ({- onClick,- selected,-}) => (- <Tooltip title={ut("Home")}>- <FocusVisibleButton- color="secondary"- aria-label={ut("Home")}- aria-pressed={selected}- onClick={onClick}- sx={{- minWidth: 0,- width: 38,- height: 38,- p: 0,- borderRadius: "12px",- color: "text.base",- '&[aria-pressed="true"]': {- color: "#FFFFFF",- bgcolor: "accent.main",- "&:hover": { bgcolor: "accent.main" },- },- }}- >- <HugeiconsIcon icon={Home01Icon} size={20} strokeWidth={1.8} />- </FocusVisibleButton>- </Tooltip>-);+const HomeButton: React.FC<{ selected: boolean }> = ({ selected }) => {+ const { goHome } = usePhotosNavigation();+ return (+ <Tooltip title={ut("Home")}>+ <FocusVisibleButton+ color="secondary"+ aria-label={ut("Home")}+ aria-pressed={selected}+ onClick={goHome}+ sx={{+ minWidth: 0,+ width: 38,+ height: 38,+ p: 0,+ borderRadius: "12px",+ color: "text.base",+ '&[aria-pressed="true"]': {+ color: "#FFFFFF",+ bgcolor: "accent.main",+ "&:hover": { bgcolor: "accent.main" },+ },+ }}+ >+ <HugeiconsIcon icon={Home01Icon} size={20} strokeWidth={1.8} />+ </FocusVisibleButton>+ </Tooltip>+ );+};const UploadButton: React.FC<ButtonishProps> = ({ onClick }) => {const disabled = uploadManager.isUploadInProgress();diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 3c320871e2..3ad05351d6 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -32,8 +32,13 @@ import {} from "@/components/gallery";import { AlbumsOverview } from "@/components/gallery/AlbumsOverview";import { DuplicatesView } from "@/components/gallery/DuplicatesView";+import { GalleryDownloadStatusNotifications } from "@/components/gallery/GalleryDownloadStatusNotifications";import { LargeFilesView } from "@/components/gallery/LargeFilesView";import { PeopleOverview } from "@/components/gallery/PeopleOverview";+import {+ PhotosNavigationProvider,+ type PhotosNavigationActions,+} from "@/components/gallery/PhotosNavigationContext";import {PhotosNavigationShell,type PhotosNavigationShellHandle,@@ -97,7 +102,6 @@ import {import { savedAuthToken } from "ente-base/token";import type { Location } from "ente-base/types";import { initContacts, pullContacts } from "ente-contacts";-import { DownloadStatusNotifications } from "ente-gallery/components/DownloadStatusNotifications";import { FullScreenDropZone } from "ente-gallery/components/FullScreenDropZone";import type { UploadTypeSelectorIntent } from "ente-gallery/components/Upload";import {@@ -832,7 +836,7 @@ const Page: React.FC = () => {setSelected(selected);};- const clearSelection = () => {+ const clearSelection = useCallback(() => {if (!selected.count) {return;}@@ -842,7 +846,7 @@ const Page: React.FC = () => {collectionID: 0,context: undefined,});- };+ }, [selected.count]);const keyboardShortcutHandlerRef = useRef({selectAll,@@ -1383,60 +1387,6 @@ const Page: React.FC = () => {[selectedFilesInView, user, remotePull],);- const handleSelectSearchOption = (- searchOption: SearchOption | undefined,- options?: { shouldExitSearchMode?: boolean },- ) => {- setIsMapView(false);- if (searchOption) {- const type = searchOption.suggestion.type;- if (type == "sidebarAction") {- const collectionID = albumShortcutCollectionID(- searchOption.suggestion.actionID,- state.uncategorizedCollectionSummaryID,- );- if (collectionID !== undefined) {- void showCollectionSummary(- collectionID,- collectionID == PseudoCollectionID.hiddenItems,- );- return;- }- }- setCleanupView(undefined);- if (type == "collection") {- dispatch({- type: "showCollectionSummary",- collectionSummaryID: searchOption.suggestion.collectionID,- });- } else if (type == "person") {- dispatch({- type: "showPerson",- personID: searchOption.suggestion.person.id,- });- } else if (type == "sidebarAction") {- navigationRef.current?.showSettings(- searchOption.suggestion.actionID,- );-- const shouldExitSearchMode =- options?.shouldExitSearchMode ?? true;- dispatch({ type: "exitSearch", shouldExitSearchMode });- } else {- if (barMode === "hidden-albums") {- dispatch({ type: "showAlbums" });- }- dispatch({- type: "enterSearchMode",- searchSuggestion: searchOption.suggestion,- });- }- } else {- const shouldExitSearchMode = options?.shouldExitSearchMode ?? true;- dispatch({ type: "exitSearch", shouldExitSearchMode });- }- };-const openUploader = (intent?: UploadTypeSelectorIntent) => {if (uploadManager.isUploadInProgress()) return;setUploadTypeSelectorView(true);@@ -1455,7 +1405,7 @@ const Page: React.FC = () => {dispatch({ type: "showCollectionSummary", collectionSummaryID });},- [],+ [dispatch, remoteFilesPull],);useEffect(() => {@@ -1476,7 +1426,76 @@ const Page: React.FC = () => {authenticateUser,handleShowCollectionSummaryWithID,),- [authenticateUser, handleShowCollectionSummaryWithID, barMode],+ [+ authenticateUser,+ handleShowCollectionSummaryWithID,+ barMode,+ lastAuthenticationForHiddenTimestamp,+ ],+ );++ const handleSelectSearchOption = useCallback(+ (+ searchOption: SearchOption | undefined,+ options?: { shouldExitSearchMode?: boolean },+ ) => {+ setIsMapView(false);+ if (searchOption) {+ const type = searchOption.suggestion.type;+ if (type == "sidebarAction") {+ const collectionID = albumShortcutCollectionID(+ searchOption.suggestion.actionID,+ state.uncategorizedCollectionSummaryID,+ );+ if (collectionID !== undefined) {+ void showCollectionSummary(+ collectionID,+ collectionID == PseudoCollectionID.hiddenItems,+ );+ return;+ }+ }+ setCleanupView(undefined);+ if (type == "collection") {+ dispatch({+ type: "showCollectionSummary",+ collectionSummaryID:+ searchOption.suggestion.collectionID,+ });+ } else if (type == "person") {+ dispatch({+ type: "showPerson",+ personID: searchOption.suggestion.person.id,+ });+ } else if (type == "sidebarAction") {+ navigationRef.current?.showSettings(+ searchOption.suggestion.actionID,+ );++ const shouldExitSearchMode =+ options?.shouldExitSearchMode ?? true;+ dispatch({ type: "exitSearch", shouldExitSearchMode });+ } else {+ if (barMode === "hidden-albums") {+ dispatch({ type: "showAlbums" });+ }+ dispatch({+ type: "enterSearchMode",+ searchSuggestion: searchOption.suggestion,+ });+ }+ } else {+ const shouldExitSearchMode =+ options?.shouldExitSearchMode ?? true;+ dispatch({ type: "exitSearch", shouldExitSearchMode });+ }+ },+ [+ barMode,+ dispatch,+ showCollectionSummary,+ state.uncategorizedCollectionSummaryID,+ ],);const handleShowCleanupView = useCallback(@@ -1493,35 +1512,25 @@ const Page: React.FC = () => {dispatch({ type: "exitSearch", shouldExitSearchMode: true });setCleanupView(view);},- [closeCollectionMap, closeSlideshow],+ [closeCollectionMap, closeSlideshow, dispatch],);- const handleDownloadStatusNotificationsShowCollectionSummary = useCallback(- (- collectionSummaryID: number | undefined,- isHiddenCollectionSummary: boolean | undefined,- ) => {- void showCollectionSummary(- collectionSummaryID,- isHiddenCollectionSummary,- );+ const handleShowPeople = useCallback(+ (onNavigate?: () => void) => {+ if (!isMLEnabled()) {+ pendingPeopleSearchReset.current = onNavigate;+ showPeopleConsent();+ return false;+ }+ onNavigate?.();+ setIsMapView(false);+ setCleanupView(undefined);+ dispatch({ type: "showPeople" });+ return true;},- [showCollectionSummary],+ [dispatch, showPeopleConsent],);- const handleShowPeople = (onNavigate?: () => void) => {- if (!isMLEnabled()) {- pendingPeopleSearchReset.current = onNavigate;- showPeopleConsent();- return false;- }- onNavigate?.();- setIsMapView(false);- setCleanupView(undefined);- dispatch({ type: "showPeople" });- return true;- };-const handleBackToPeople = useCallback(() => {setCleanupView(undefined);setSelected({@@ -1531,14 +1540,17 @@ const Page: React.FC = () => {context: undefined,});dispatch({ type: "showPeople" });- }, []);+ }, [dispatch]);- const handleShowAlbumOverview = (filter: AlbumFilter) => {- setCleanupView(undefined);- clearSelection();- setAlbumFilter(filter);- dispatch({ type: "showAlbumOverview", albumFilter: filter });- };+ const handleShowAlbumOverview = useCallback(+ (filter: AlbumFilter) => {+ setCleanupView(undefined);+ clearSelection();+ setAlbumFilter(filter);+ dispatch({ type: "showAlbumOverview", albumFilter: filter });+ },+ [clearSelection, dispatch],+ );const handleBackToAlbums = useCallback(() => {setCleanupView(undefined);@@ -1556,22 +1568,25 @@ const Page: React.FC = () => {});setAlbumFilter(filter);dispatch({ type: "showAlbumOverview", albumFilter: filter });- }, [albumOpenedFromOverview, collectionSummary?.id]);+ }, [albumOpenedFromOverview, collectionSummary?.id, dispatch]);- const handleChangeBarMode = (mode: GalleryBarMode) => {- if (mode == "links") {+ const handleChangeBarMode = useCallback(+ (mode: GalleryBarMode) => {+ if (mode == "links") {+ setCleanupView(undefined);+ clearSelection();+ dispatch({ type: "showLinks" });+ return true;+ }+ if (mode == "people") {+ return handleShowPeople();+ }setCleanupView(undefined);- clearSelection();- dispatch({ type: "showLinks" });+ handleShowAlbumOverview("ente");return true;- }- if (mode == "people") {- return handleShowPeople();- }- setCleanupView(undefined);- handleShowAlbumOverview("ente");- return true;- };+ },+ [clearSelection, dispatch, handleShowAlbumOverview, handleShowPeople],+ );const handleFileViewerToggleFavorite = useCallback(async (file: EnteFile) => {@@ -1677,7 +1692,7 @@ const Page: React.FC = () => {collectionSummaryID: collectionID,});},- [closeCollectionMap],+ [closeCollectionMap, dispatch],);const handleSelectPerson = useCallback(@@ -1687,7 +1702,7 @@ const Page: React.FC = () => {closeCollectionMap();dispatch({ type: "showPerson", personID });},- [closeCollectionMap],+ [closeCollectionMap, dispatch],);const handleOpenCollectionSelector = useCallback(@@ -2016,17 +2031,101 @@ const Page: React.FC = () => {!suppressContextSelectionBar &&!(isContextMenuOpen && selected.count === 1);+ const selectGalleryCollection = useCallback(+ (collectionID: number) => {+ if (barMode == "links") {+ dispatch({ type: "selectLink", collectionID });+ } else {+ handleShowCollectionSummaryWithID(collectionID);+ }+ },+ [barMode, dispatch, handleShowCollectionSummaryWithID],+ );+ const handleGoHome = useCallback(() => {+ setIsMapView(false);+ handleShowCollectionSummaryWithID(PseudoCollectionID.all);+ }, [handleShowCollectionSummaryWithID]);+ const handleChangeMode = useCallback(+ (mode: GalleryBarMode) => {+ const changed = handleChangeBarMode(mode);+ if (changed) setIsMapView(false);+ return changed;+ },+ [handleChangeBarMode],+ );+ const handleShowLibraryMap = useCallback(() => {+ setSelectedPlace(undefined);+ handleShowCollectionSummaryWithID(PseudoCollectionID.all);+ handleShowCollectionMap();+ }, [handleShowCollectionSummaryWithID, handleShowCollectionMap]);+ const handleSelectPlace = useCallback(+ (place: PlaceSelection | undefined) => {+ setSelectedPlace(place);+ setPlaceSelectionRevision((revision) => revision + 1);+ },+ [],+ );+ const handleOpenOverviewAlbum = useCallback(+ (collectionID: number) => {+ handleShowCollectionSummaryWithID(collectionID);+ setAlbumOpenedFromOverview({+ collectionID,+ filter: overviewFilter!,+ searchQuery: albumSearchQuery,+ });+ },+ [handleShowCollectionSummaryWithID, overviewFilter, albumSearchQuery],+ );+ const handleShowLinksOverview = useCallback(+ () => handleChangeBarMode("links"),+ [handleChangeBarMode],+ );+ const navigationActions = useMemo<PhotosNavigationActions>(+ () => ({+ goHome: handleGoHome,+ changeMode: handleChangeMode,+ showLibraryMap: handleShowLibraryMap,+ showCollectionMap: handleShowCollectionMap,+ selectPlace: handleSelectPlace,+ showCollectionSummary,+ selectCollection: selectGalleryCollection,+ selectCollectionFromViewer: handleSelectCollection,+ openOverviewAlbum: handleOpenOverviewAlbum,+ showAlbumOverview: handleShowAlbumOverview,+ backToAlbums: handleBackToAlbums,+ showLinksOverview: handleShowLinksOverview,+ showPeople: handleShowPeople,+ selectPerson: handleSelectPerson,+ backToPeople: handleBackToPeople,+ selectSearchOption: handleSelectSearchOption,+ showCleanupView: handleShowCleanupView,+ }),+ [+ handleGoHome,+ handleChangeMode,+ handleShowLibraryMap,+ handleShowCollectionMap,+ handleSelectPlace,+ showCollectionSummary,+ selectGalleryCollection,+ handleSelectCollection,+ handleOpenOverviewAlbum,+ handleShowAlbumOverview,+ handleBackToAlbums,+ handleShowLinksOverview,+ handleShowPeople,+ handleSelectPerson,+ handleBackToPeople,+ handleSelectSearchOption,+ handleShowCleanupView,+ ],+ );+if (!user) {// Children rely on user after the mount dispatch.return <div></div>;}- const selectGalleryCollection =- barMode == "links"- ? (collectionID: number) =>- dispatch({ type: "selectLink", collectionID })- : handleShowCollectionSummaryWithID;-const collectionMap = activeCollectionSummary && (<CollectionMapcollectionSummary={activeCollectionSummary}@@ -2047,13 +2146,11 @@ const Page: React.FC = () => {fileNormalCollectionIDs={fileNormalCollectionIDs}collectionNameByID={collectionNameByID}emailByUserID={state.emailByUserID}- onSelectCollection={handleSelectCollection}- onSelectPerson={handleSelectPerson}/>);return (- <>+ <PhotosNavigationProvider value={navigationActions}><FullScreenDropZonemessage={watchFolderView@@ -2080,11 +2177,8 @@ const Page: React.FC = () => {findCollectionCreatingIfNeeded(state.collections, id)}/>- <DownloadStatusNotifications+ <GalleryDownloadStatusNotifications{...{ saveGroups, onRemoveSaveGroup }}- onShowCollectionSummary={- handleDownloadStatusNotificationsShowCollectionSummary- }/><FixCreationTime{...fixCreationTimeVisibilityProps}@@ -2096,7 +2190,6 @@ const Page: React.FC = () => {isFirstLoad={isFirstLoad}isInSearchMode={isInSearchMode}collectionNameByID={collectionNameByID}- onShowCleanupView={handleShowCleanupView}onAuthenticateUser={authenticateUser}mode={barMode}isMapView={isMapView}@@ -2104,39 +2197,12 @@ const Page: React.FC = () => {isMapView &&activeCollectionID === PseudoCollectionID.all}- onChangeMode={(mode) => {- const changed = handleChangeBarMode(mode);- if (changed) setIsMapView(false);- return changed;- }}onUpload={openUploader}- onShowMap={() => {- setSelectedPlace(undefined);- handleShowCollectionSummaryWithID(- PseudoCollectionID.all,- );- handleShowCollectionMap();- }}- onHome={() => {- setIsMapView(false);- handleShowCollectionSummaryWithID(- PseudoCollectionID.all,- );- }}- onSelectSearchOption={handleSelectSearchOption}- onSelectPeople={handleShowPeople}- onSelectPerson={handleSelectPerson}galleryNavigation={isCleanupViewOpen? undefined: {selectedPlace,- onSelectPlace: (place) => {- setSelectedPlace(place);- setPlaceSelectionRevision(- (revision) => revision + 1,- );- },placesFiles:isMapView &&activeCollectionID ===@@ -2145,23 +2211,16 @@ const Page: React.FC = () => {: undefined,activeCollectionID:galleryBarActiveCollectionID,- onSelectCollectionID: selectGalleryCollection,onRemotePull: remotePull,activePerson,albumFilter,albumSearchQuery,onAlbumSearchQueryChange: setAlbumSearchQuery,- onShowAlbumOverview: handleShowAlbumOverview,- onShowPeopleOverview: handleShowPeople,- onShowLinksOverview: () =>- handleChangeBarMode("links"),collectionSummaries:sidebarCollectionSummaries,visibleAlbumFilters: sidebarAlbumFilters,uncategorizedCollectionSummaryID:state.uncategorizedCollectionSummaryID,- onShowCollectionSummary:- showCollectionSummary,collectionsSortBy,onChangeCollectionsSortBy,peopleSortBy,@@ -2227,19 +2286,14 @@ const Page: React.FC = () => {isActiveCollectionDownloadInProgress,onAddSaveGroup,}}- onBackToAlbums={handleBackToAlbums}showBackToAlbums={albumOpenedFromOverview !== undefined &&albumOpenedFromOverview.collectionID ===collectionSummary?.id}- onBackToPeople={handleBackToPeople}mode={barMode}shouldHide={isInSearchMode}- setActiveCollectionID={selectGalleryCollection}- onSelectPerson={handleSelectPerson}onEditAlbumDetails={showEditAlbumDetails}- onShowMap={handleShowCollectionMap}onCollectionSlideshow={startSlideshow}emailByUserID={state.emailByUserID}shareSuggestionEmails={@@ -2277,7 +2331,6 @@ const Page: React.FC = () => {filter="links"searchQuery={albumSearchQuery}sortBy={collectionsSortBy}- onSelectAlbum={selectGalleryCollection}onCreateAlbum={showAlbumNameInput}onRemotePull={remotePull}/>@@ -2302,14 +2355,6 @@ const Page: React.FC = () => {filter={overviewFilter!}searchQuery={albumSearchQuery}sortBy={collectionsSortBy}- onSelectAlbum={(collectionID) => {- handleShowCollectionSummaryWithID(collectionID);- setAlbumOpenedFromOverview({- collectionID,- filter: overviewFilter!,- searchQuery: albumSearchQuery,- });- }}onCreateAlbum={() => {setPostCreateAlbumOp(undefined);postCreateAlbumHidden.current = false;@@ -2324,7 +2369,6 @@ const Page: React.FC = () => {people={state.view.visiblePeople}allPeople={state.view.people}peopleSortBy={peopleSortBy}- onSelectPerson={handleSelectPerson}/>) : (<FileListWithViewer@@ -2379,8 +2423,6 @@ const Page: React.FC = () => {onRemotePull={remotePull}onRemoteFilesPull={remoteFilesPull}onVisualFeedback={handleVisualFeedback}- onSelectCollection={handleSelectCollection}- onSelectPerson={handleSelectPerson}onAddFileToCollection={handleAddSingleFileToCollection}@@ -2506,7 +2548,7 @@ const Page: React.FC = () => {files={selectedFilesInView}onConfirm={handleEditLocationConfirm}/>- </>+ </PhotosNavigationProvider>);};diff --git a/web/apps/photos/tests/sidebar-album-search.test.tsx b/web/apps/photos/tests/sidebar-album-search.test.tsxindex 29b3c6b169..92cb53e5d8 100644--- a/web/apps/photos/tests/sidebar-album-search.test.tsx+++ b/web/apps/photos/tests/sidebar-album-search.test.tsx@@ -8,6 +8,10 @@ import {GalleryBarImpl,type GalleryBarImplProps,} from "../src/components/gallery/BarImpl";+import {+ PhotosNavigationProvider,+ type PhotosNavigationActions,+} from "../src/components/gallery/PhotosNavigationContext";import { useAlbumNavigationData } from "../src/components/gallery/use-album-navigation-data";const viewport = vi.hoisted(() => ({ scrollToEnd: false }));@@ -116,16 +120,28 @@ const renderSearch = (collapsed: false,mobileDrawerProps: { open: false, onClose: vi.fn() },onAlbumSearchQueryChange: vi.fn(),- onShowAlbumOverview: vi.fn(),- onShowPeopleOverview: vi.fn(),- onShowLinksOverview: vi.fn(),- onShowCollectionSummary: vi.fn(),- onSelectCollectionID: vi.fn(),onCreateAlbum: vi.fn(),onChangeCollectionsSortBy: vi.fn(),onChangePeopleSortBy: vi.fn(),- onSelectPerson: vi.fn(),- onSelectPlace: vi.fn(),+ };+ const navigation: PhotosNavigationActions = {+ goHome: vi.fn(),+ changeMode: vi.fn(() => true),+ showLibraryMap: vi.fn(),+ showCollectionMap: vi.fn(),+ selectPlace: vi.fn(),+ showCollectionSummary: vi.fn(() => Promise.resolve(true)),+ selectCollection: vi.fn(),+ selectCollectionFromViewer: vi.fn(),+ openOverviewAlbum: vi.fn(),+ showAlbumOverview: vi.fn(),+ backToAlbums: vi.fn(),+ showLinksOverview: vi.fn(() => true),+ showPeople: vi.fn(() => true),+ selectPerson: vi.fn(),+ backToPeople: vi.fn(),+ selectSearchOption: vi.fn(),+ showCleanupView: vi.fn(),};const Sidebar = () => {const data = useAlbumNavigationData({@@ -134,11 +150,13 @@ const renderSearch = (});return (<ThemeProvider theme={photosTheme}>- <GalleryBarImpl- {...props}- {...data}- collectionSummaries={data.sidebarCollectionSummaries}- />+ <PhotosNavigationProvider value={navigation}>+ <GalleryBarImpl+ {...props}+ {...data}+ collectionSummaries={data.sidebarCollectionSummaries}+ />+ </PhotosNavigationProvider></ThemeProvider>);};