Skip to content

armgit / ente

Public Imported from GitHub
0

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

[photos][web] Use shared subscription sidebar action

AswinAsokbf04b75b8986
diff --git a/web/apps/photos/src/components/sidebar/Sidebar.tsx b/web/apps/photos/src/components/sidebar/Sidebar.tsx
index 40e799b577..30b6d77fb0 100644
--- a/web/apps/photos/src/components/sidebar/Sidebar.tsx
+++ b/web/apps/photos/src/components/sidebar/Sidebar.tsx
@@ -73,11 +73,9 @@ import { openManageSubscription } from "./accounts/subscription";
import { Preferences, type PreferencesAction } from "./preferences/Preferences";
import { sidebarTheme } from "./theme";
-export type SidebarPendingAction = SidebarActionID | "subscription";
-
type SidebarProps = ModalVisibilityProps & {
- pendingAction?: SidebarPendingAction;
- onActionHandled?: (actionID: SidebarPendingAction) => void;
+ pendingAction?: SidebarActionID;
+ onActionHandled?: (actionID: SidebarActionID) => void;
onShowLargeFiles: () => void;
onShowDuplicates: () => void;
setLoading: (loading: boolean) => void;
@@ -242,12 +240,8 @@ export const Sidebar: React.FC<SidebarProps> = ({
]);
const performSidebarAction = useCallback(
- async (actionID: SidebarPendingAction) => {
+ async (actionID: SidebarActionID) => {
if (actionID !== "utility.export") closeSections();
- if (actionID === "subscription") {
- onShowPlanSelector();
- return;
- }
return performSidebarRegistryAction(actionID, {
onClose,
onShowPlanSelector,
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index bcd4871a5f..0f6783f25e 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -48,10 +48,7 @@ import {
type GalleryBarMode,
} from "@/components/gallery/reducer";
import { useAlbumNavigationData } from "@/components/gallery/use-album-navigation-data";
-import {
- Sidebar,
- type SidebarPendingAction,
-} from "@/components/sidebar/Sidebar";
+import { Sidebar } from "@/components/sidebar/Sidebar";
import {
notifyOthersFilesDialogAttributes,
notifyUnsupportedSharedFavoritesDialogAttributes,
@@ -171,7 +168,10 @@ import {
filterSearchableFiles,
updateSearchCollectionsAndFiles,
} from "ente-new/photos/services/search";
-import type { SearchOption } from "ente-new/photos/services/search/types";
+import type {
+ SearchOption,
+ SidebarActionID,
+} from "ente-new/photos/services/search/types";
import {
initSettings,
updateMapEnabled,
@@ -287,7 +287,7 @@ const Page: React.FC = () => {
>(undefined);
const postCreateAlbumHidden = useRef(false);
const [pendingSidebarAction, setPendingSidebarAction] = useState<
- SidebarPendingAction | undefined
+ SidebarActionID | undefined
>(undefined);
const lastAuthenticationForHiddenTimestamp = useRef<number>(0);
diff --git a/web/apps/photos/src/services/search/sidebar-search-registry.ts b/web/apps/photos/src/services/search/sidebar-search-registry.ts
index 85da3c45a2..2be8060a1a 100644
--- a/web/apps/photos/src/services/search/sidebar-search-registry.ts
+++ b/web/apps/photos/src/services/search/sidebar-search-registry.ts
@@ -319,6 +319,10 @@ export const performSidebarAction = async (
ctx: SidebarActionContext,
): Promise<void> => {
switch (actionID) {
+ case "subscription":
+ ctx.onShowPlanSelector();
+ return Promise.resolve();
+
case "utility.account":
ctx.showAccount();
return Promise.resolve();
diff --git a/web/packages/new/photos/services/search/types.ts b/web/packages/new/photos/services/search/types.ts
index 84cb222789..73370dab9d 100644
--- a/web/packages/new/photos/services/search/types.ts
+++ b/web/packages/new/photos/services/search/types.ts
@@ -6,6 +6,7 @@ import type { Person } from "ente-new/photos/services/ml/people";
import type { LocationTag } from "../user-entity";
export type SidebarActionID =
+ | "subscription"
| "shortcuts.uncategorized"
| "shortcuts.archive"
| "shortcuts.hidden"