From acf3740a6827912923a5c2b57c3171d89a727488 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Tue, 14 May 2024 13:24:48 +0500 Subject: [PATCH] mobile: fix pricing plans stuck at loading --- apps/mobile/app/hooks/use-pricing.ts | 13 ++++--------- packages/core/src/api/index.ts | 2 +- packages/core/src/api/pricing.ts | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/apps/mobile/app/hooks/use-pricing.ts b/apps/mobile/app/hooks/use-pricing.ts index 116e5dc3f6..a4e41db93c 100644 --- a/apps/mobile/app/hooks/use-pricing.ts +++ b/apps/mobile/app/hooks/use-pricing.ts @@ -22,20 +22,14 @@ import { Platform } from "react-native"; import { Subscription } from "react-native-iap"; import PremiumService from "../services/premium"; import { db } from "../common/database"; +import { Product } from "@notesnook/core/dist/api/pricing"; -type PurchaseInfo = { - country: string; - countryCode: string; - sku: string; - discount: number; -}; - -const skuInfos: { [name: string]: PurchaseInfo | undefined } = {}; +const skuInfos: { [name: string]: Product | undefined } = {}; export const usePricing = (period: "monthly" | "yearly") => { const [current, setCurrent] = useState<{ period: string; - info?: PurchaseInfo; + info?: Product; product?: Subscription; }>(); @@ -54,6 +48,7 @@ export const usePricing = (period: "monthly" | "yearly") => { period )); skuInfos[period] = skuInfo; + const products = (await PremiumService.getProducts()) as Subscription[]; let product = products.find((p) => p.productId === skuInfo?.sku); if (!product) diff --git a/packages/core/src/api/index.ts b/packages/core/src/api/index.ts index 5049d3801c..8f77ab0521 100644 --- a/packages/core/src/api/index.ts +++ b/packages/core/src/api/index.ts @@ -179,7 +179,7 @@ class Database { subscriptions = new Subscriptions(this.tokenManager); offers = new Offers(); debug = new Debug(); - pricing = new Pricing(); + pricing = Pricing; user = new UserManager(this); syncer = new Sync(this); diff --git a/packages/core/src/api/pricing.ts b/packages/core/src/api/pricing.ts index 587b6f82e8..a4f165f97e 100644 --- a/packages/core/src/api/pricing.ts +++ b/packages/core/src/api/pricing.ts @@ -19,7 +19,7 @@ along with this program. If not, see . import http from "../utils/http"; -type Product = { +export type Product = { country: string; countryCode: string; sku?: string;