mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
mobile: paywall fixes
This commit is contained in:
committed by
Abdullah Atta
parent
cdca90bd54
commit
fdbac8e608
@@ -75,6 +75,7 @@ import { IconButton } from "../ui/icon-button";
|
||||
import { SvgView } from "../ui/svg";
|
||||
import Heading from "../ui/typography/heading";
|
||||
import Paragraph from "../ui/typography/paragraph";
|
||||
import { ToastManager } from "../../services/event-manager";
|
||||
|
||||
const Steps = {
|
||||
select: 1,
|
||||
@@ -106,6 +107,8 @@ const PayWall = (props: NavigationProps<"PayWall">) => {
|
||||
onFocus: () => true
|
||||
});
|
||||
|
||||
console.log(pricingPlans.user?.subscription);
|
||||
|
||||
useEffect(() => {
|
||||
let listener: NativeEventSubscription;
|
||||
if (isFocused) {
|
||||
@@ -999,10 +1002,26 @@ const PricingPlanCard = ({
|
||||
pricingPlans?.currentPlan?.id
|
||||
);
|
||||
|
||||
const isSubscribed =
|
||||
product?.productId &&
|
||||
pricingPlans?.user?.subscription.productId.includes(plan.id) &&
|
||||
pricingPlans.isSubscribed();
|
||||
|
||||
return (
|
||||
<TouchableOpacity
|
||||
activeOpacity={0.8}
|
||||
onPress={() => {
|
||||
if (
|
||||
isSubscribed &&
|
||||
pricingPlans?.user?.subscription.productId === product.productId
|
||||
) {
|
||||
ToastManager.show({
|
||||
message: "You are already subscribed to this plan.",
|
||||
type: "info"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
pricingPlans?.selectPlan(plan.id);
|
||||
setStep(Steps.buy);
|
||||
}}
|
||||
@@ -1039,9 +1058,7 @@ const PricingPlanCard = ({
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{product?.productId &&
|
||||
pricingPlans?.user?.subscription.productId.includes(plan.id) &&
|
||||
pricingPlans.isSubscribed() ? (
|
||||
{isSubscribed ? (
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: colors.primary.accent,
|
||||
|
||||
@@ -20,7 +20,7 @@ import { Plan } from "@notesnook/core";
|
||||
import { strings } from "@notesnook/intl";
|
||||
import { useThemeColors } from "@notesnook/theme";
|
||||
import dayjs from "dayjs";
|
||||
import React, { useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { ScrollView, Text, TouchableOpacity, View } from "react-native";
|
||||
import Config from "react-native-config";
|
||||
import * as RNIap from "react-native-iap";
|
||||
@@ -362,6 +362,7 @@ const ProductItem = (props: {
|
||||
}}
|
||||
activeOpacity={0.9}
|
||||
onPress={() => {
|
||||
if (isSubscribed) return;
|
||||
if (!product) return;
|
||||
props.pricingPlans.selectProduct(
|
||||
isGithubRelease
|
||||
|
||||
@@ -225,7 +225,11 @@ const onUserEmailVerified = async () => {
|
||||
const onUserSubscriptionStatusChanged = async (
|
||||
subscription: User["subscription"]
|
||||
) => {
|
||||
if (!PremiumService.get() && subscription.plan !== SubscriptionPlan.FREE) {
|
||||
if (
|
||||
subscription &&
|
||||
subscription.plan !== SubscriptionPlan.FREE &&
|
||||
subscription.plan !== useUserStore.getState().user?.subscription.plan
|
||||
) {
|
||||
PremiumService.subscriptions.clear();
|
||||
useUserStore.setState({
|
||||
user: {
|
||||
@@ -237,6 +241,7 @@ const onUserSubscriptionStatusChanged = async (
|
||||
}
|
||||
await PremiumService.setPremiumStatus();
|
||||
useMessageStore.getState().setAnnouncement();
|
||||
useUserStore.getState().setUser(await db.user.fetchUser());
|
||||
};
|
||||
|
||||
const onRequestPartialSync = async (
|
||||
|
||||
@@ -379,6 +379,14 @@ const usePricingPlans = (options?: PricingPlansOptions) => {
|
||||
sku: product?.productId,
|
||||
obfuscatedAccountIdAndroid: user.id,
|
||||
obfuscatedProfileIdAndroid: user.id,
|
||||
purchaseTokenAndroid:
|
||||
user.subscription?.plan !== SubscriptionPlan.FREE
|
||||
? user.subscription?.googlePurchaseToken || undefined
|
||||
: undefined,
|
||||
replacementModeAndroid: user.subscription?.googlePurchaseToken
|
||||
? RNIap.ReplacementModesAndroid.WITH_TIME_PRORATION
|
||||
: undefined,
|
||||
|
||||
/**
|
||||
* iOS
|
||||
*/
|
||||
|
||||
@@ -134,38 +134,6 @@ const SettingsUserSection = ({ item }) => {
|
||||
const userProfile = useUserStore((state) => state.profile);
|
||||
const used = user?.storageUsed || 0;
|
||||
const total = user?.totalStorage || 0;
|
||||
const subscriptionProviderInfo =
|
||||
strings.subscriptionProviderInfo[user?.subscription?.provider];
|
||||
|
||||
const getSubscriptionStatus = () => {
|
||||
if (!user) return strings.neverHesitate();
|
||||
const subscriptionDaysLeft = user && getTimeLeft(user.subscription?.expiry);
|
||||
const expiryDate = dayjs(user?.subscription?.expiry).format(
|
||||
"dddd, MMMM D, YYYY h:mm A"
|
||||
);
|
||||
const startDate = dayjs(user?.subscription?.start).format(
|
||||
"dddd, MMMM D, YYYY h:mm A"
|
||||
);
|
||||
|
||||
if (user.subscription.plan !== SubscriptionPlan.FREE) {
|
||||
const status = user.subscription.status;
|
||||
return status === SubscriptionStatus.TRIAL
|
||||
? strings.trialEndsOn(
|
||||
dayjs(user?.subscription?.start)
|
||||
.add(user?.subscription?.productId.includes("monthly") ? 7 : 14)
|
||||
.format("dddd, MMMM D, YYYY h:mm A")
|
||||
)
|
||||
: status === SubscriptionStatus.ACTIVE
|
||||
? strings.subRenewOn(expiryDate)
|
||||
: status === SubscriptionStatus.CANCELED
|
||||
? strings.subEndsOn(expiryDate)
|
||||
: status === SubscriptionStatus.EXPIRED
|
||||
? subscriptionDaysLeft.time < -3
|
||||
? strings.subEnded()
|
||||
: strings.accountDowngradedIn(3)
|
||||
: strings.neverHesitate();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -378,17 +346,17 @@ const SettingsUserSection = ({ item }) => {
|
||||
: strings.upgradePlan()
|
||||
}
|
||||
onPress={() => {
|
||||
// if (
|
||||
// user.subscription.plan !== SubscriptionPlan.FREE &&
|
||||
// user.subscription.productId.includes("5year")
|
||||
// ) {
|
||||
// ToastManager.show({
|
||||
// message:
|
||||
// "You have made a one time purchase. To change your plan please contact support.",
|
||||
// type: "info"
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
if (
|
||||
user.subscription.plan !== SubscriptionPlan.FREE &&
|
||||
user.subscription.productId.includes("5year")
|
||||
) {
|
||||
ToastManager.show({
|
||||
message:
|
||||
"You have made a one time purchase. To change your plan please contact support.",
|
||||
type: "info"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Navigation.navigate("PayWall", {
|
||||
context: "logged-in",
|
||||
|
||||
1
apps/monograph/package-lock.json
generated
1
apps/monograph/package-lock.json
generated
@@ -190,6 +190,7 @@
|
||||
"react-colorful": "^5.6.1",
|
||||
"redent": "^4.0.0",
|
||||
"refractor": "^4.8.1",
|
||||
"simplebar-react": "^3.3.2",
|
||||
"strip-indent": "^4.0.0",
|
||||
"unfurl.js": "^6.4.0"
|
||||
},
|
||||
|
||||
3
apps/theme-builder/package-lock.json
generated
3
apps/theme-builder/package-lock.json
generated
@@ -987,11 +987,10 @@
|
||||
},
|
||||
"../web": {
|
||||
"name": "@notesnook/web",
|
||||
"version": "3.2.3",
|
||||
"version": "3.3.0-beta.1",
|
||||
"hasInstallScript": true,
|
||||
"license": "GPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@brixtol/currency-symbols": "^1.1.1",
|
||||
"@dnd-kit/core": "^6.1.0",
|
||||
"@dnd-kit/modifiers": "^7.0.0",
|
||||
"@dnd-kit/sortable": "^8.0.0",
|
||||
|
||||
1394
apps/web/package-lock.json
generated
1394
apps/web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user