This commit is contained in:
Manav Rathi
2025-06-26 07:45:08 +05:30
parent 1babaf529e
commit ef4b9ebc42
5 changed files with 18 additions and 17 deletions

View File

@@ -102,8 +102,8 @@ import {
isSubscriptionPastDue,
isSubscriptionStripe,
leaveFamily,
pullUserDetails,
redirectToCustomerPortal,
syncUserDetails,
userDetailsAddOnBonuses,
type UserDetails,
} from "ente-new/photos/services/user-details";
@@ -230,7 +230,7 @@ const UserDetailsSection: React.FC<UserDetailsSectionProps> = ({
} = useModalVisibility();
useEffect(() => {
if (sidebarOpen) void syncUserDetails();
if (sidebarOpen) void pullUserDetails();
}, [sidebarOpen]);
const isNonAdminFamilyMember = useMemo(

View File

@@ -91,7 +91,7 @@ import {
import type { SearchOption } from "ente-new/photos/services/search/types";
import { initSettings } from "ente-new/photos/services/settings";
import {
initUserDetailsOrTriggerSync,
initUserDetailsOrTriggerPull,
redirectToCustomerPortal,
userDetailsSnapshot,
verifyStripeSubscription,
@@ -296,7 +296,7 @@ const Page: React.FC = () => {
return;
}
initSettings();
await initUserDetailsOrTriggerSync();
await initUserDetailsOrTriggerPull();
setupSelectAllKeyBoardShortcutHandler();
dispatch({ type: "showAll" });
setIsFirstLoad(isFirstLogin());

View File

@@ -18,7 +18,7 @@ import {
savedCollectionFiles,
savedCollections,
} from "ente-new/photos/services/photos-fdb";
import { getUserDetailsV2 } from "ente-new/photos/services/user-details";
import { userDetailsSnapshot } from "ente-new/photos/services/user-details";
const DATE_TIME_PARSING_TEST_FILE_NAMES = [
{
@@ -170,7 +170,7 @@ export async function testUpload() {
}
async function totalFileCountCheck(expectedState) {
const userDetails = await getUserDetailsV2();
const userDetails = userDetailsSnapshot();
if (expectedState.total_file_count === userDetails.fileCount) {
console.log("file count check passed ✅");
} else {

View File

@@ -56,7 +56,7 @@ class MLState {
*
* - On app start, this is read from local storage during {@link initML}.
*
* - It gets updated when we sync with remote (so if the user
* - It gets updated when we pull from remote (so if the user
* enables/disables ML on a different device, this local value will also
* become true/false).
*

View File

@@ -183,12 +183,12 @@ export const logoutUserDetails = () => {
*
* This assumes that the user is already logged in.
*/
export const initUserDetailsOrTriggerSync = async () => {
export const initUserDetailsOrTriggerPull = async () => {
const saved = await getKV("userDetails");
if (saved) {
setUserDetailsSnapshot(UserDetails.parse(saved));
} else {
void syncUserDetails();
void pullUserDetails();
}
};
@@ -231,8 +231,8 @@ const setUserDetailsSnapshot = (snapshot: UserDetails) => {
* Fetch the user's details from remote and save them in local storage for
* subsequent lookup, and also update our in-memory snapshots.
*/
export const syncUserDetails = async () => {
const userDetails = await getUserDetailsV2();
export const pullUserDetails = async () => {
const userDetails = await getUserDetails();
await setKV("userDetails", userDetails);
setUserDetailsSnapshot(userDetails);
@@ -248,7 +248,7 @@ export const syncUserDetails = async () => {
/**
* Fetch the user details for the currently logged in user from remote.
*/
export const getUserDetailsV2 = async () => {
const getUserDetails = async () => {
const res = await fetch(await apiURL("/users/details/v2"), {
headers: await authenticatedRequestHeaders(),
});
@@ -326,7 +326,7 @@ export const verifyStripeSubscription = async (
}),
}),
);
await syncUserDetails();
await pullUserDetails();
return userDetailsSnapshot()!.subscription;
};
@@ -342,7 +342,7 @@ export const activateStripeSubscription = async () => {
headers: await authenticatedRequestHeaders(),
}),
);
return syncUserDetails();
return pullUserDetails();
};
/**
@@ -356,7 +356,7 @@ export const cancelStripeSubscription = async () => {
headers: await authenticatedRequestHeaders(),
}),
);
return syncUserDetails();
return pullUserDetails();
};
const paymentsAppOrigin = "https://payments.ente.io";
@@ -539,7 +539,8 @@ const getFamiliesTokenAndURL = async () => {
/**
* Update remote to indicate that the user wants to leave the family plan that
* they are part of, then our local sync user details with remote.
* they are part of, then update our local user details by pulling the latest
* ones from remote.
*/
export const leaveFamily = async () => {
ensureOk(
@@ -548,7 +549,7 @@ export const leaveFamily = async () => {
headers: await authenticatedRequestHeaders(),
}),
);
return syncUserDetails();
return pullUserDetails();
};
/**