From 6249211bca6429ddddb66e8acdd2bd563e3e79ab Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Thu, 3 Jul 2025 15:21:17 +0530 Subject: [PATCH] Rename --- web/apps/photos/src/pages/gallery.tsx | 9 +++++---- web/packages/new/photos/services/user-details.ts | 14 +++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx index 4d8b4a2f56..1fea4027fb 100644 --- a/web/apps/photos/src/pages/gallery.tsx +++ b/web/apps/photos/src/pages/gallery.tsx @@ -108,8 +108,8 @@ import { import type { SearchOption } from "ente-new/photos/services/search/types"; import { initSettings } from "ente-new/photos/services/settings"; import { - initUserDetailsOrTriggerPull, redirectToCustomerPortal, + savedUserDetailsOrTriggerPull, userDetailsSnapshot, verifyStripeSubscription, } from "ente-new/photos/services/user-details"; @@ -301,7 +301,6 @@ const Page: React.FC = () => { // One time inits. preloadImage("/images/subscription-card-background"); initSettings(); - await initUserDetailsOrTriggerPull(); setupSelectAllKeyBoardShortcutHandler(); // Show the initial state while the rest of the sequence proceeds. @@ -318,10 +317,12 @@ const Page: React.FC = () => { } // Initialize the reducer. + const user = ensureLocalUser(); + const userDetails = await savedUserDetailsOrTriggerPull(); dispatch({ type: "mount", - user: ensureLocalUser(), - familyData: userDetailsSnapshot()?.familyData, + user, + familyData: userDetails?.familyData, collections: await savedCollections(), collectionFiles: await savedCollectionFiles(), trashItems: await savedTrashItems(), diff --git a/web/packages/new/photos/services/user-details.ts b/web/packages/new/photos/services/user-details.ts index 4d48d7449e..2a99fdafcb 100644 --- a/web/packages/new/photos/services/user-details.ts +++ b/web/packages/new/photos/services/user-details.ts @@ -177,18 +177,22 @@ export const logoutUserDetails = () => { }; /** - * Read in the locally persisted settings into memory, otherwise initiate a - * network requests to fetch the latest values (but don't wait for it to - * complete). + * Read in the locally persisted user details into memory and return them. + * + * If there are no locally persisted values, initiate a network requests to + * fetch the latest values (but don't wait for it to complete). * * This assumes that the user is already logged in. */ -export const initUserDetailsOrTriggerPull = async () => { +export const savedUserDetailsOrTriggerPull = async () => { const saved = await getKV("userDetails"); if (saved) { - setUserDetailsSnapshot(UserDetails.parse(saved)); + const userDetails = UserDetails.parse(saved); + setUserDetailsSnapshot(userDetails); + return userDetails; } else { void pullUserDetails(); + return undefined; } };