π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web][photos] Fix plan state updates and signup loading
AswinAsok9edd594f4a47
diff --git a/web/apps/photos/src/components/PlanSelector.tsx b/web/apps/photos/src/components/PlanSelector.tsxindex 4474e86f47..afa91ca328 100644--- a/web/apps/photos/src/components/PlanSelector.tsx+++ b/web/apps/photos/src/components/PlanSelector.tsx@@ -120,7 +120,7 @@ export const PlanSelector: React.FC<PlanSelectorProps> = ({export type PlanSelectorContentsProps = Pick<PlanSelectorProps,"onClose" | "setLoading" | "onManageFamily" | "initialPlansData"-> & { onBeginCheckout?: () => void };+> & { onBeginCheckout?: () => void; showInitialLoading?: boolean };export const PlanSelectorContents: React.FC<PlanSelectorContentsProps> = ({onClose,@@ -128,6 +128,7 @@ export const PlanSelectorContents: React.FC<PlanSelectorContentsProps> = ({initialPlansData,onManageFamily,onBeginCheckout,+ showInitialLoading = false,}) => {const { showMiniDialog } = useBaseContext();const showCloseButton = !useContext(SidebarPanelContext);@@ -154,11 +155,13 @@ export const PlanSelectorContents: React.FC<PlanSelectorContentsProps> = ({useEffect(() => {const request = { cancelled: false };+ const showFetchLoading = showInitialLoading && !initialPlansData;+ if (showFetchLoading) setLoading(true);void (async () => {try {const plansData = initialPlansData ?? (await getPlansData());if (request.cancelled) return;- const { plans } = plansData;+ const plans = [...plansData.plans];if (subscription && isSubscriptionActive(subscription)) {const activePlan = plans.find((plan) =>isSubscriptionForPlan(subscription, plan),@@ -175,16 +178,19 @@ export const PlanSelectorContents: React.FC<PlanSelectorContentsProps> = ({});}}- setPlansData(plansData);+ setPlansData({ ...plansData, plans });} catch (e) {if (request.cancelled) return;log.error("Failed to get plans", e);onClose();showMiniDialog(genericRetriableErrorDialogAttributes());+ } finally {+ if (showFetchLoading && !request.cancelled) setLoading(false);}})();return () => {request.cancelled = true;+ if (showFetchLoading) setLoading(false);};// eslint-disable-next-line react-hooks/exhaustive-deps}, []);diff --git a/web/apps/photos/src/pages/plan.tsx b/web/apps/photos/src/pages/plan.tsxindex 472aee6db8..4d3f9fe01f 100644--- a/web/apps/photos/src/pages/plan.tsx+++ b/web/apps/photos/src/pages/plan.tsx@@ -45,6 +45,7 @@ function PlanPage(): JSX.Element {<><PhotosAuthShell contentWidth={420}><PlanSelectorContents+ showInitialLoadingonClose={handleContinue}setLoading={setIsLoading}onManageFamily={handleContinue}