Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: fix pricing plans stuck at loading

Ammar Ahmedacf3740a6827
diff --git a/apps/mobile/app/hooks/use-pricing.ts b/apps/mobile/app/hooks/use-pricing.ts
index 116e5dc3f..a4e41db93 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 5049d3801..8f77ab052 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 587b6f82e..a4f165f97 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 <http://www.gnu.org/licenses/>.
import http from "../utils/http";
-type Product = {
+export type Product = {
country: string;
countryCode: string;
sku?: string;