Skip to content

Commit

Permalink
mobile: fix pricing plans stuck at loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed May 16, 2024
1 parent 8423543 commit acf3740
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
13 changes: 4 additions & 9 deletions apps/mobile/app/hooks/use-pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}>();

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/api/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit acf3740

Please sign in to comment.