Skip to content

armgit / ente

Public Imported from GitHub
0

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

refactor(photos):use-navigation-context-provider-directly

Aswin Asok9508a1c24ab0
diff --git a/web/apps/photos/src/components/gallery/PhotosNavigationContext.tsx b/web/apps/photos/src/components/gallery/PhotosNavigationContext.tsx
index 99966d3cc8..27077c2841 100644
--- a/web/apps/photos/src/components/gallery/PhotosNavigationContext.tsx
+++ b/web/apps/photos/src/components/gallery/PhotosNavigationContext.tsx
@@ -30,18 +30,15 @@ export interface PhotosNavigationActions {
showCleanupView: (view: "large-files" | "duplicates") => void;
}
-const PhotosNavigationContext = createContext<
+export 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",
+ "usePhotosNavigation must be used within PhotosNavigationContext.Provider",
);
}
return actions;
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index cc7ccf3754..6aef62e023 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -35,7 +35,7 @@ import { DuplicatesView } from "@/components/gallery/DuplicatesView";
import { LargeFilesView } from "@/components/gallery/LargeFilesView";
import { PeopleOverview } from "@/components/gallery/PeopleOverview";
import {
- PhotosNavigationProvider,
+ PhotosNavigationContext,
type PhotosNavigationActions,
} from "@/components/gallery/PhotosNavigationContext";
import {
@@ -2158,7 +2158,7 @@ const Page: React.FC = () => {
);
return (
- <PhotosNavigationProvider value={navigationActions}>
+ <PhotosNavigationContext.Provider value={navigationActions}>
<FullScreenDropZone
message={
watchFolderView
@@ -2559,7 +2559,7 @@ const Page: React.FC = () => {
files={selectedFilesInView}
onConfirm={handleEditLocationConfirm}
/>
- </PhotosNavigationProvider>
+ </PhotosNavigationContext.Provider>
);
};
diff --git a/web/apps/photos/tests/sidebar-album-search.test.tsx b/web/apps/photos/tests/sidebar-album-search.test.tsx
index 92cb53e5d8..e76a941b20 100644
--- a/web/apps/photos/tests/sidebar-album-search.test.tsx
+++ b/web/apps/photos/tests/sidebar-album-search.test.tsx
@@ -9,7 +9,7 @@ import {
type GalleryBarImplProps,
} from "../src/components/gallery/BarImpl";
import {
- PhotosNavigationProvider,
+ PhotosNavigationContext,
type PhotosNavigationActions,
} from "../src/components/gallery/PhotosNavigationContext";
import { useAlbumNavigationData } from "../src/components/gallery/use-album-navigation-data";
@@ -150,13 +150,13 @@ const renderSearch = (
});
return (
<ThemeProvider theme={photosTheme}>
- <PhotosNavigationProvider value={navigation}>
+ <PhotosNavigationContext.Provider value={navigation}>
<GalleryBarImpl
{...props}
{...data}
collectionSummaries={data.sidebarCollectionSummaries}
/>
- </PhotosNavigationProvider>
+ </PhotosNavigationContext.Provider>
</ThemeProvider>
);
};