Remove intermediary
This commit is contained in:
@@ -13,7 +13,6 @@ import {
|
||||
type CollectionsSortBy,
|
||||
type CollectionSummaries,
|
||||
} from "@/new/photos/services/collection/ui";
|
||||
import { AppContext } from "@/new/photos/types/context";
|
||||
import { includes } from "@/utils/type-guards";
|
||||
import {
|
||||
getData,
|
||||
@@ -24,13 +23,7 @@ import AllCollections from "components/Collections/AllCollections";
|
||||
import { SetCollectionNamerAttributes } from "components/Collections/CollectionNamer";
|
||||
import CollectionShare from "components/Collections/CollectionShare";
|
||||
import { ITEM_TYPE, TimeStampListItem } from "components/PhotoList";
|
||||
import React, {
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { sortCollectionSummaries } from "services/collectionService";
|
||||
import { SetFilesDownloadProgressAttributesCreator } from "types/gallery";
|
||||
import { ALL_SECTION } from "utils/collection";
|
||||
@@ -101,8 +94,6 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
|
||||
filesDownloadProgressAttributesList,
|
||||
setFilesDownloadProgressAttributesCreator,
|
||||
}) => {
|
||||
const appContext = useContext(AppContext);
|
||||
|
||||
const [openAllCollectionDialog, setOpenAllCollectionDialog] =
|
||||
useState(false);
|
||||
const [openCollectionShareView, setOpenCollectionShareView] =
|
||||
@@ -174,7 +165,7 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
|
||||
) : activePerson ? (
|
||||
<PeopleHeader
|
||||
person={activePerson}
|
||||
{...{ onSelectPerson, people, appContext }}
|
||||
{...{ onSelectPerson, people }}
|
||||
/>
|
||||
) : (
|
||||
<></>
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
import { t } from "i18next";
|
||||
import React, { useEffect, useState, useSyncExternalStore } from "react";
|
||||
import { Trans } from "react-i18next";
|
||||
import { useAppContext, type NewAppContextPhotos } from "../types/context";
|
||||
import { useAppContext, type AppContextT } from "../types/context";
|
||||
import { openURL } from "../utils/web";
|
||||
import { useWrapAsyncOperation } from "./use-wrap-async";
|
||||
|
||||
@@ -253,7 +253,7 @@ interface ManageMLProps {
|
||||
/** Called when the user wants to disable ML. */
|
||||
onDisableML: () => void;
|
||||
/** Subset of appContext. */
|
||||
setDialogBoxAttributesV2: NewAppContextPhotos["setDialogBoxAttributesV2"];
|
||||
setDialogBoxAttributesV2: AppContextT["setDialogBoxAttributesV2"];
|
||||
}
|
||||
|
||||
const ManageML: React.FC<ManageMLProps> = ({
|
||||
|
||||
@@ -16,7 +16,7 @@ import { t } from "i18next";
|
||||
import React, { useState } from "react";
|
||||
import type { FaceCluster } from "../../services/ml/cluster";
|
||||
import type { CGroup } from "../../services/user-entity";
|
||||
import type { NewAppContextPhotos } from "../../types/context";
|
||||
import { useAppContext } from "../../types/context";
|
||||
import { AddPersonDialog } from "../AddPersonDialog";
|
||||
import { SpaceBetweenFlex } from "../mui";
|
||||
import { NameInputDialog } from "../NameInputDialog";
|
||||
@@ -50,14 +50,12 @@ type PeopleHeaderProps = Pick<
|
||||
"people" | "onSelectPerson"
|
||||
> & {
|
||||
person: Person;
|
||||
appContext: NewAppContextPhotos;
|
||||
};
|
||||
|
||||
export const PeopleHeader: React.FC<PeopleHeaderProps> = ({
|
||||
people,
|
||||
onSelectPerson,
|
||||
person,
|
||||
appContext,
|
||||
}) => {
|
||||
return (
|
||||
<GalleryItemsHeaderAdapter>
|
||||
@@ -72,12 +70,12 @@ export const PeopleHeader: React.FC<PeopleHeaderProps> = ({
|
||||
{person.type == "cgroup" ? (
|
||||
<CGroupPersonOptions
|
||||
cgroup={person.cgroup}
|
||||
{...{ onSelectPerson, appContext }}
|
||||
{...{ onSelectPerson }}
|
||||
/>
|
||||
) : (
|
||||
<ClusterPersonOptions
|
||||
cluster={person.cluster}
|
||||
{...{ people, appContext }}
|
||||
{...{ people }}
|
||||
/>
|
||||
)}
|
||||
</SpaceBetweenFlex>
|
||||
@@ -85,16 +83,12 @@ export const PeopleHeader: React.FC<PeopleHeaderProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
type CGroupPersonOptionsProps = Pick<
|
||||
PeopleHeaderProps,
|
||||
"appContext" | "onSelectPerson"
|
||||
> & {
|
||||
type CGroupPersonOptionsProps = Pick<PeopleHeaderProps, "onSelectPerson"> & {
|
||||
cgroup: CGroup;
|
||||
};
|
||||
|
||||
const CGroupPersonOptions: React.FC<CGroupPersonOptionsProps> = ({
|
||||
cgroup,
|
||||
appContext,
|
||||
onSelectPerson,
|
||||
}) => {
|
||||
const {
|
||||
@@ -102,7 +96,7 @@ const CGroupPersonOptions: React.FC<CGroupPersonOptionsProps> = ({
|
||||
finishLoading,
|
||||
onGenericError,
|
||||
setDialogBoxAttributesV2,
|
||||
} = appContext;
|
||||
} = useAppContext();
|
||||
|
||||
const [openAddNameInput, setOpenAddNameInput] = useState(false);
|
||||
|
||||
@@ -182,19 +176,15 @@ const CGroupPersonOptions: React.FC<CGroupPersonOptionsProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
type ClusterPersonOptionsProps = Pick<
|
||||
PeopleHeaderProps,
|
||||
"people" | "appContext"
|
||||
> & {
|
||||
type ClusterPersonOptionsProps = Pick<PeopleHeaderProps, "people"> & {
|
||||
cluster: FaceCluster;
|
||||
};
|
||||
|
||||
const ClusterPersonOptions: React.FC<ClusterPersonOptionsProps> = ({
|
||||
people,
|
||||
cluster,
|
||||
appContext,
|
||||
}) => {
|
||||
const { startLoading, finishLoading } = appContext;
|
||||
const { startLoading, finishLoading } = useAppContext();
|
||||
|
||||
const [openNameInput, setOpenNameInput] = useState(false);
|
||||
const [openAddPersonDialog, setOpenAddPersonDialog] = useState(false);
|
||||
|
||||
@@ -1,33 +1,14 @@
|
||||
import type { AccountsContextT } from "@/accounts/types/context";
|
||||
import { ensure } from "@/utils/ensure";
|
||||
import type { SetDialogBoxAttributes } from "@ente/shared/components/DialogBox/types";
|
||||
import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
|
||||
import { THEME_COLOR } from "@ente/shared/themes/constants";
|
||||
import { createContext, useContext } from "react";
|
||||
import type { SetNotificationAttributes } from "./notification";
|
||||
|
||||
/**
|
||||
* A subset of the AppContext type used by the photos app.
|
||||
*
|
||||
* [Note: Migrating components that need the app context]
|
||||
*
|
||||
* This only exists to make it easier to migrate code into the @/new package.
|
||||
* Once we move this code back (after TypeScript strict mode migration is done),
|
||||
* then the code that uses this can start directly using the actual app context
|
||||
* instead of needing to explicitly pass a prop of this type.
|
||||
* */
|
||||
export interface NewAppContextPhotos {
|
||||
startLoading: () => void;
|
||||
finishLoading: () => void;
|
||||
setDialogBoxAttributesV2: (attrs: DialogBoxAttributesV2) => void;
|
||||
somethingWentWrong: () => void;
|
||||
onGenericError: (error: unknown) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of the React context available to all pages in the photos app.
|
||||
*/
|
||||
type AppContextT = AccountsContextT & {
|
||||
export type AppContextT = AccountsContextT & {
|
||||
/**
|
||||
* Show the global activity indicator (a green bar at the top of the page).
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user