From 454f93fadb280af3f4f9797c237373bb71d3f620 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 24 Sep 2024 09:35:19 +0530 Subject: [PATCH] rename --- .../Collections/AllCollections/index.tsx | 6 ++-- .../src/components/Collections/index.tsx | 36 ++++++++++--------- web/apps/photos/src/pages/gallery.tsx | 2 +- .../new/photos/components/Gallery/BarImpl.tsx | 34 ++++++++++-------- 4 files changed, 42 insertions(+), 36 deletions(-) diff --git a/web/apps/photos/src/components/Collections/AllCollections/index.tsx b/web/apps/photos/src/components/Collections/AllCollections/index.tsx index 903694f3ba..d40e9322b4 100644 --- a/web/apps/photos/src/components/Collections/AllCollections/index.tsx +++ b/web/apps/photos/src/components/Collections/AllCollections/index.tsx @@ -23,7 +23,7 @@ interface AllCollectionsProps { open: boolean; onClose: () => void; collectionSummaries: CollectionSummary[]; - setActiveCollectionID: (id?: number) => void; + onSelectCollectionID: (id: number) => void; collectionsSortBy: CollectionsSortBy; onChangeCollectionsSortBy: (by: CollectionsSortBy) => void; isInHiddenSection: boolean; @@ -36,7 +36,7 @@ export default function AllCollections(props: AllCollectionsProps) { collectionSummaries, open, onClose, - setActiveCollectionID, + onSelectCollectionID, collectionsSortBy, onChangeCollectionsSortBy, isInHiddenSection, @@ -44,7 +44,7 @@ export default function AllCollections(props: AllCollectionsProps) { const isMobile = useMediaQuery("(max-width: 428px)"); const onCollectionClick = (collectionID: number) => { - setActiveCollectionID(collectionID); + onSelectCollectionID(collectionID); onClose(); }; diff --git a/web/apps/photos/src/components/Collections/index.tsx b/web/apps/photos/src/components/Collections/index.tsx index 40b6ecf428..203bff37b4 100644 --- a/web/apps/photos/src/components/Collections/index.tsx +++ b/web/apps/photos/src/components/Collections/index.tsx @@ -1,9 +1,8 @@ import type { Collection } from "@/media/collection"; import { GalleryBarImpl, - type GalleryBarMode, + type GalleryBarImplProps, } from "@/new/photos/components/Gallery/BarImpl"; -import type { Person } from "@/new/photos/services/ml/cgroups"; import { collectionsSortBy, type CollectionsSortBy, @@ -36,31 +35,34 @@ import { } from "../FilesDownloadProgress"; import { AlbumCastDialog } from "./AlbumCastDialog"; -interface CollectionsProps { - /** `true` if the bar should be hidden altogether. */ +type CollectionsProps = Omit< + GalleryBarImplProps, + | "collectionSummaries" + | "hiddenCollectionSummaries" + | "onSelectCollectionID" + | "collectionsSortBy" + | "onChangeCollectionsSortBy" + | "onShowAllCollections" +> & { + /** + * When `true`, the bar is be hidden altogether. + */ shouldHide: boolean; - /** otherwise show stuff that belongs to this mode. */ - mode: GalleryBarMode; - setMode: (mode: GalleryBarMode) => void; collectionSummaries: CollectionSummaries; activeCollection: Collection; - activeCollectionID?: number; - setActiveCollectionID: (id?: number) => void; + setActiveCollectionID: (collectionID: number) => void; hiddenCollectionSummaries: CollectionSummaries; - people: Person[]; - activePerson: Person | undefined; - onSelectPerson: (person: Person) => void; setCollectionNamerAttributes: SetCollectionNamerAttributes; setPhotoListHeader: (value: TimeStampListItem) => void; filesDownloadProgressAttributesList: FilesDownloadProgressAttributes[]; setFilesDownloadProgressAttributesCreator: SetFilesDownloadProgressAttributesCreator; -} +}; // TODO-Cluster Rename me to GalleryBar and subsume GalleryBarImpl export const Collections: React.FC = ({ shouldHide, mode, - setMode, + onChangeMode, collectionSummaries, activeCollection, activeCollectionID, @@ -165,14 +167,14 @@ export const Collections: React.FC = ({ setOpenAllCollectionDialog(true)} collectionSummaries={sortedCollectionSummaries.filter((x) => @@ -186,7 +188,7 @@ export const Collections: React.FC = ({ collectionSummaries={sortedCollectionSummaries.filter( (x) => !isSystemCollection(x.type), )} - setActiveCollectionID={setActiveCollectionID} + onSelectCollectionID={setActiveCollectionID} onChangeCollectionsSortBy={setCollectionsSortBy} collectionsSortBy={collectionsSortBy} isInHiddenSection={mode == "hidden-albums"} diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx index 20adc9dbd2..2d2c4a4bf8 100644 --- a/web/apps/photos/src/pages/gallery.tsx +++ b/web/apps/photos/src/pages/gallery.tsx @@ -1116,7 +1116,7 @@ export default function Gallery() { void; + onChangeMode: (mode: GalleryBarMode) => void; /** * Massaged data about the collections that should be shown in the bar. */ collectionSummaries: CollectionSummary[]; /** - * The ID of the currently active collection (if any) + * The ID of the currently active collection (if any). + * + * Required if mode is not "albums" or "hidden-albums". */ - activeCollectionID: number; + activeCollectionID: number | undefined; /** - * Called when the user changes the active collection. + * Called when the user selects a new collection in the bar. + * + * This callback is passed the id of the selected collection. */ - setActiveCollectionID: (id?: number) => void; + onSelectCollectionID: (collectionID: number) => void; /** * Called when the user selects the option to show a modal with all the * collections. @@ -83,23 +87,23 @@ export interface GalleryBarImplProps { */ people: Person[]; /** - * The currently selected person (if any). + * The currently selected person. * * Required if mode is "people". */ activePerson: Person | undefined; /** - * Called when the user selects the given person in the bar. + * Called when the user selects a new person in the bar. */ onSelectPerson: (person: Person) => void; } export const GalleryBarImpl: React.FC = ({ mode, - setMode, + onChangeMode, collectionSummaries, activeCollectionID, - setActiveCollectionID, + onSelectCollectionID, onShowAllCollections, collectionsSortBy, onChangeCollectionsSortBy, @@ -194,8 +198,8 @@ export const GalleryBarImpl: React.FC = ({ ? { type: "collections", collectionSummaries, - activeCollectionID, - onCollectionClick: setActiveCollectionID, + activeCollectionID: ensure(activeCollectionID), + onCollectionClick: onSelectCollectionID, } : { type: "people", @@ -207,7 +211,7 @@ export const GalleryBarImpl: React.FC = ({ mode, collectionSummaries, activeCollectionID, - setActiveCollectionID, + onSelectCollectionID, people, activePerson, onSelectPerson, @@ -242,7 +246,7 @@ export const GalleryBarImpl: React.FC = ({ return ( - + {controls1} @@ -299,7 +303,7 @@ export const Row2 = styled(Box)` `; const ModeIndicator: React.FC< - Pick + Pick > = ({ mode }) => (