web: fix infinite rerenders on checkout screen

This commit is contained in:
Abdullah Atta
2025-06-06 11:01:14 +05:00
parent 5601ab0bc3
commit 9eda07d233
3 changed files with 17 additions and 19 deletions

View File

@@ -34,21 +34,18 @@ import { ScrollContainer } from "@notesnook/ui";
import useMobile from "../../hooks/use-mobile";
import { logger } from "../../utils/logger";
import { isFeatureSupported } from "../../utils/feature-check";
import { isDev } from "./plans";
// const isDev = false; // import.meta.env.DEV;
const VENDOR_ID = import.meta.env.DEV || IS_TESTING ? 1506 : 128190;
const PADDLE_ORIGIN =
import.meta.env.DEV || IS_TESTING
? "https://sandbox-buy.paddle.com"
: "https://buy.paddle.com";
const SUBSCRIPTION_MANAGEMENT_URL =
import.meta.env.DEV || IS_TESTING
? "https://sandbox-subscription-management.paddle.com"
: "https://subscription-management.paddle.com";
const CHECKOUT_SERVICE_ORIGIN =
import.meta.env.DEV || IS_TESTING
? "https://sandbox-checkout-service.paddle.com"
: "https://checkout-service.paddle.com";
const VENDOR_ID = isDev ? 1506 : 128190;
const PADDLE_ORIGIN = isDev
? "https://sandbox-buy.paddle.com"
: "https://buy.paddle.com";
const SUBSCRIPTION_MANAGEMENT_URL = isDev
? "https://sandbox-subscription-management.paddle.com"
: "https://subscription-management.paddle.com";
const CHECKOUT_SERVICE_ORIGIN = isDev
? "https://sandbox-checkout-service.paddle.com"
: "https://checkout-service.paddle.com";
const SUBSCRIBED_EVENTS: PaddleEvents[] = [
PaddleEvents["Checkout.Loaded"],

View File

@@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useEffect, useState } from "react";
import { Period, Plan } from "./types";
type PlanMetadata = {
@@ -26,8 +25,10 @@ type PlanMetadata = {
subtitle: string;
};
export const isDev = import.meta.env.DEV || IS_TESTING;
export const EDUCATION_PLAN: Plan = {
id: import.meta.env.DEV || IS_TESTING ? "50305" : "658759",
id: isDev ? "50305" : "658759",
period: "education",
country: "US",
currency: "USD",
@@ -43,7 +44,7 @@ export const DEFAULT_PLANS: Plan[] = [
currency: "USD",
discount: { type: "regional", amount: 0, recurring: false },
originalPrice: { gross: 4.49, net: 0, tax: 0 },
id: import.meta.env.DEV || IS_TESTING ? "9822" : "648884",
id: isDev ? "9822" : "648884",
price: { gross: 4.49, net: 0, tax: 0 }
},
{
@@ -51,7 +52,7 @@ export const DEFAULT_PLANS: Plan[] = [
country: "PK",
currency: "USD",
discount: { type: "regional", amount: 0, recurring: false },
id: import.meta.env.DEV || IS_TESTING ? "50305" : "658759",
id: isDev ? "50305" : "658759",
price: { gross: 49.99, net: 0, tax: 0 },
originalPrice: { gross: 49.99, net: 0, tax: 0 }
},

View File

@@ -201,7 +201,7 @@ export function HeadlessAuth(props: AuthProps) {
performance.mark("load:auth");
setIsReady(true);
});
}, [route, openURL]);
}, [route]);
if (!isReady) return <></>;