Skip to content

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

mobile: minor fixes

Ammar Ahmedaf91a6ee9848
diff --git a/apps/mobile/app/common/database/index.ts b/apps/mobile/app/common/database/index.ts
index 924eec028..3d3a9959a 100644
--- a/apps/mobile/app/common/database/index.ts
+++ b/apps/mobile/app/common/database/index.ts
@@ -38,7 +38,7 @@ export async function setupDatabase(password?: string) {
const key = await getDatabaseKey(password);
if (!key) throw new Error(strings.databaseSetupFailed());
- const base = `http://192.168.100.83`;
+ const base = `http://192.168.100.88`;
database.host({
API_HOST: `${base}:5264`,
diff --git a/apps/mobile/app/components/auth/signup.js b/apps/mobile/app/components/auth/signup.js
index aef4c603f..efbe730f3 100644
--- a/apps/mobile/app/components/auth/signup.js
+++ b/apps/mobile/app/components/auth/signup.js
@@ -206,6 +206,7 @@ export const Signup = ({ changeMode, welcome }) => {
onChangeText={(value) => {
email.current = value;
}}
+ defaultValue={email.current}
testID="input.email"
onErrorCheck={(e) => setError(e)}
returnKeyLabel="Next"
@@ -228,6 +229,7 @@ export const Signup = ({ changeMode, welcome }) => {
onChangeText={(value) => {
password.current = value;
}}
+ defaultValue={password.current}
testID="input.password"
onErrorCheck={(e) => setError(e)}
returnKeyLabel="Next"
@@ -250,6 +252,7 @@ export const Signup = ({ changeMode, welcome }) => {
onChangeText={(value) => {
confirmPassword.current = value;
}}
+ defaultValue={confirmPassword.current}
testID="input.confirmPassword"
onErrorCheck={(e) => setError(e)}
returnKeyLabel="Signup"
diff --git a/apps/mobile/app/components/paywall/index.tsx b/apps/mobile/app/components/paywall/index.tsx
index e5a8d06eb..962e1b35d 100644
--- a/apps/mobile/app/components/paywall/index.tsx
+++ b/apps/mobile/app/components/paywall/index.tsx
@@ -85,18 +85,19 @@ const Steps = {
const PayWall = (props: NavigationProps<"PayWall">) => {
const isGithubRelease = Config.GITHUB_RELEASE === "true";
const routeParams = props.route.params;
- const { width, height } = useWindowDimensions();
+ const { width } = useWindowDimensions();
const isTablet = width > 600;
- const [webUrl, setWebUrl] = useState("https://notesnook.com");
const { colors } = useThemeColors();
const pricingPlans = usePricingPlans({
planId: routeParams.state?.planId,
- productId: routeParams.state?.productId
+ productId: routeParams.state?.productId,
+ onBuy: () => {
+ setStep(Steps.finish);
+ }
});
const [annualBilling, setAnnualBilling] = useState(
routeParams.state ? routeParams.state.billingType === "annual" : true
);
- const [ctaButtonVisible, setCtaButtonVisible] = useState(false);
const [step, setStep] = useState(
routeParams.state ? Steps.buy : Steps.select
);
@@ -105,7 +106,24 @@ const PayWall = (props: NavigationProps<"PayWall">) => {
onFocus: () => true
});
- console.log(pricingPlans.user?.subscription);
+ useEffect(() => {
+ if (routeParams.state) {
+ if (routeParams.state?.planId) {
+ pricingPlans.selectPlan(
+ routeParams.state?.planId,
+ routeParams.state?.productId
+ );
+ console.log(
+ "selectPlan",
+ routeParams.state?.planId,
+ routeParams.state?.productId,
+ (pricingPlans.selectedProduct as any).productId
+ );
+ }
+ setStep(Steps.buy);
+ console.log("Buy step");
+ }
+ }, [routeParams.state]);
useEffect(() => {
let listener: NativeEventSubscription;
@@ -212,13 +230,6 @@ const PayWall = (props: NavigationProps<"PayWall">) => {
}}
keyboardDismissMode="none"
keyboardShouldPersistTaps="always"
- onScroll={(event) => {
- if (event.nativeEvent.contentOffset.y > 1000) {
- setCtaButtonVisible(true);
- } else {
- setCtaButtonVisible(false);
- }
- }}
>
<View
style={{
@@ -603,28 +614,8 @@ After trying all the privacy security oriented note taking apps, for the price a
) : step === Steps.buy ? (
<BuyPlan
planId={pricingPlans.currentPlan?.id as string}
- productId={
- annualBilling &&
- pricingPlans.user?.subscription.productId !==
- `notesnook.${pricingPlans?.currentPlan?.id as string}.yearly`
- ? Config.GITHUB_RELEASE === "true"
- ? "yearly"
- : `notesnook.${pricingPlans?.currentPlan?.id as string}.yearly`
- : Config.GITHUB_RELEASE === "true"
- ? "monthly"
- : `notesnook.${pricingPlans?.currentPlan?.id as string}.monthly`
- }
canActivateTrial={pricingPlans.userCanRequestTrial}
- goBack={() => {
- setStep(Steps.select);
- }}
- goNext={(product) => {
- pricingPlans.selectProduct(
- (product as RNIap.Subscription).productId ||
- (product as Plan).period
- );
- setStep(Steps.finish);
- }}
+ pricingPlans={pricingPlans}
/>
) : step === Steps.finish ? (
<View
@@ -949,14 +940,15 @@ const PricingPlanCard = ({
const { colors } = useThemeColors();
const isFreePlan = plan.id === "free";
const [regionalDiscount, setRegionaDiscount] = useState<SKUResponse>();
- const { width, height } = useWindowDimensions();
+ const { width } = useWindowDimensions();
const isTablet = width > 600;
const product =
plan.subscriptions?.[
- `notesnook.${plan.id}.${annualBilling ? "yearly" : "monthly"}`
+ regionalDiscount?.sku ||
+ `notesnook.${plan.id}.${annualBilling ? "yearly" : "monthly"}`
];
-
+ console.log(regionalDiscount?.sku);
const price = pricingPlans?.getPrice(
product as RNIap.Subscription,
pricingPlans.hasTrialOffer(plan.id, product?.productId) ? 1 : 0,
@@ -974,23 +966,41 @@ const PricingPlanCard = ({
plan.id,
pricingPlans.isGithubRelease
? (WebPlan?.period as string)
- : (product?.productId as string)
+ : `notesnook.${plan.id}.${annualBilling ? "yearly" : "monthly"}`
)
.then((value) => {
setRegionaDiscount(value);
});
- }, [pricingPlans, plan, product, WebPlan]);
+ }, []);
const isSubscribed =
product?.productId &&
- pricingPlans?.user?.subscription.productId.includes(plan.id) &&
+ pricingPlans?.user?.subscription?.productId?.includes(plan.id) &&
pricingPlans.isSubscribed();
return (
<TouchableOpacity
activeOpacity={0.8}
onPress={() => {
- pricingPlans?.selectPlan(plan.id);
+ const currentPlanSubscribed =
+ pricingPlans?.user?.subscription?.productId ===
+ (product as RNIap.Subscription)?.productId ||
+ pricingPlans?.user?.subscription?.productId.startsWith(
+ (product as RNIap.Subscription)?.productId
+ );
+
+ pricingPlans?.selectPlan(
+ plan.id,
+ currentPlanSubscribed
+ ? `notesnook.${plan.id}.${
+ !(product as RNIap.Subscription)?.productId.includes("yearly")
+ ? "yearly"
+ : "monthly"
+ }`
+ : pricingPlans.isGithubRelease
+ ? (WebPlan?.period as string)
+ : (product?.productId as string)
+ );
setStep(Steps.buy);
}}
style={{
@@ -1021,7 +1031,8 @@ const PricingPlanCard = ({
}}
>
<Heading color={colors.static.white} size={AppFontSize.xs}>
- {regionalDiscount?.discount}% Off
+ {strings.specialOffer()}{" "}
+ {strings.percentOff(`${regionalDiscount?.discount}`)}
</Heading>
</View>
) : null}
diff --git a/apps/mobile/app/components/sheets/buy-plan/index.tsx b/apps/mobile/app/components/sheets/buy-plan/index.tsx
index ffeb3b035..6a33f1982 100644
--- a/apps/mobile/app/components/sheets/buy-plan/index.tsx
+++ b/apps/mobile/app/components/sheets/buy-plan/index.tsx
@@ -16,11 +16,11 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { Plan } from "@notesnook/core";
+import { Plan, SKUResponse } 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";
@@ -38,22 +38,12 @@ import Paragraph from "../../ui/typography/paragraph";
const isGithubRelease = Config.GITHUB_RELEASE === "true";
export const BuyPlan = (props: {
planId: string;
- productId: string;
canActivateTrial?: boolean;
- goBack: () => void;
- goNext: (
- product: Plan | RNIap.Subscription | RNIap.Product | undefined
- ) => void;
+ pricingPlans: ReturnType<typeof usePricingPlans>;
}) => {
const { colors } = useThemeColors();
const [checkoutUrl, setCheckoutUrl] = useState<string>();
- const pricingPlans = usePricingPlans({
- planId: props.planId,
- productId: props.productId,
- onBuy: () => {
- props.goNext(pricingPlans.selectedProduct);
- }
- });
+ const pricingPlans = props.pricingPlans;
const billingDuration = pricingPlans.getBillingDuration(
pricingPlans.selectedProduct as RNIap.Subscription,
@@ -81,7 +71,7 @@ export const BuyPlan = (props: {
try {
const data = JSON.parse(message.nativeEvent.data);
if (data.success) {
- props.goNext(pricingPlans.selectedProduct);
+ pricingPlans.finish();
}
} catch (e) {}
}}
@@ -326,8 +316,11 @@ const ProductItem = (props: {
productId: string;
}) => {
const { colors } = useThemeColors();
+ const [regionalDiscount, setRegionaDiscount] = useState<SKUResponse>();
const product =
- props.pricingPlans?.currentPlan?.subscriptions?.[props.productId] ||
+ props.pricingPlans?.currentPlan?.subscriptions?.[
+ regionalDiscount?.sku || props.productId
+ ] ||
props.pricingPlans?.currentPlan?.products?.[props.productId] ||
props.pricingPlans?.getWebPlan(
props.pricingPlans?.currentPlan?.id as string,
@@ -336,7 +329,7 @@ const ProductItem = (props: {
const isAnnual = isGithubRelease
? (product as Plan)?.period === "yearly"
- : (product as RNIap.Subscription)?.productId.includes("yearly");
+ : (product as RNIap.Subscription)?.productId?.includes("yearly");
const isSelected = isGithubRelease
? (product as Plan)?.period ===
@@ -352,9 +345,36 @@ const ProductItem = (props: {
const isSubscribed =
props.pricingPlans.isSubscribed() &&
- (props.pricingPlans.user?.subscription.productId ===
- (product as RNIap.Subscription).productId ||
- props.pricingPlans.user?.subscription.productId === (product as Plan).id);
+ (props.pricingPlans.user?.subscription?.productId ===
+ (product as RNIap.Subscription)?.productId ||
+ props.pricingPlans.user?.subscription?.productId.startsWith(
+ (product as RNIap.Subscription)?.productId
+ ) ||
+ props.pricingPlans.user?.subscription?.productId ===
+ (product as Plan).id);
+
+ useEffect(() => {
+ props.pricingPlans
+ ?.getRegionalDiscount(
+ props.pricingPlans.currentPlan?.id as string,
+ props.pricingPlans.isGithubRelease
+ ? ((product as Plan)?.period as string)
+ : props.productId
+ )
+ .then((value) => {
+ if (
+ value &&
+ value.sku?.startsWith(
+ (props.pricingPlans.selectedProduct as RNIap.Subscription)
+ ?.productId
+ )
+ ) {
+ props.pricingPlans.selectProduct(value?.sku as string);
+ }
+ setRegionaDiscount(value);
+ });
+ }, []);
+
return (
<TouchableOpacity
style={{
@@ -413,7 +433,9 @@ const ProductItem = (props: {
<Heading color={colors.static.white} size={AppFontSize.xs}>
{strings.bestValue()} -{" "}
{strings.percentOff(
- (isGithubRelease
+ (regionalDiscount
+ ? regionalDiscount.discount
+ : isGithubRelease
? (product as Plan).discount?.amount
: props.pricingPlans.compareProductPrice(
props.pricingPlans.currentPlan?.id as string,
diff --git a/apps/mobile/app/components/sheets/plan-limits/index.tsx b/apps/mobile/app/components/sheets/plan-limits/index.tsx
index 549e9652c..d15c11649 100644
--- a/apps/mobile/app/components/sheets/plan-limits/index.tsx
+++ b/apps/mobile/app/components/sheets/plan-limits/index.tsx
@@ -8,18 +8,22 @@ import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import { useEffect, useState } from "react";
import { View } from "react-native";
+import { ScrollView } from "react-native-actions-sheet";
+import { eSendEvent, ToastManager } from "../../../services/event-manager";
+import Navigation from "../../../services/navigation";
+import { eCloseSheet } from "../../../utils/events";
import { AppFontSize } from "../../../utils/size";
import { DefaultAppStyles } from "../../../utils/styles";
-import Paragraph from "../../ui/typography/paragraph";
-import Heading from "../../ui/typography/heading";
-import Navigation from "../../../services/navigation";
import { Button } from "../../ui/button";
-import { eSendEvent } from "../../../services/event-manager";
-import { eCloseSheet } from "../../../utils/events";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
+import { SubscriptionPlan, SubscriptionProvider } from "@notesnook/core";
+import { useUserStore } from "../../../stores/use-user-store";
export function PlanLimits() {
const { colors } = useThemeColors();
const [featureUsage, setFeatureUsage] = useState<FeatureUsage[]>();
+ const user = useUserStore((state) => state.user);
useEffect(() => {
getFeaturesUsage()
@@ -30,11 +34,13 @@ export function PlanLimits() {
}, []);
return (
- <View
+ <ScrollView
style={{
paddingHorizontal: DefaultAppStyles.GAP,
width: "100%",
- paddingVertical: DefaultAppStyles.GAP_VERTICAL,
+ paddingVertical: DefaultAppStyles.GAP_VERTICAL
+ }}
+ contentContainerStyle={{
gap: DefaultAppStyles.GAP_VERTICAL
}}
>
@@ -71,22 +77,38 @@ export function PlanLimits() {
</View>
))}
- <Button
- title={strings.upgradePlan()}
- onPress={() => {
- Navigation.navigate("PayWall", {
- context: "logged-in",
- canGoBack: true
- });
- eSendEvent(eCloseSheet);
- }}
- type="accent"
- fontSize={AppFontSize.xs}
- style={{
- width: "100%",
- marginTop: DefaultAppStyles.GAP_VERTICAL
- }}
- />
- </View>
+ {user?.subscription.provider === SubscriptionProvider.PADDLE ||
+ user?.subscription.provider ===
+ SubscriptionProvider.STREETWRITERS ? null : (
+ <Button
+ title={strings.changePlan()}
+ 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",
+ context: "local"
+ });
+ return;
+ }
+ Navigation.navigate("PayWall", {
+ context: "logged-in",
+ canGoBack: true
+ });
+ eSendEvent(eCloseSheet);
+ }}
+ type="accent"
+ fontSize={AppFontSize.xs}
+ style={{
+ width: "100%",
+ marginTop: DefaultAppStyles.GAP_VERTICAL
+ }}
+ />
+ )}
+ </ScrollView>
);
}
diff --git a/apps/mobile/app/hooks/use-app-events.tsx b/apps/mobile/app/hooks/use-app-events.tsx
index 87bc1d0c6..08781636d 100644
--- a/apps/mobile/app/hooks/use-app-events.tsx
+++ b/apps/mobile/app/hooks/use-app-events.tsx
@@ -228,7 +228,7 @@ const onUserSubscriptionStatusChanged = async (
if (
subscription &&
subscription.plan !== SubscriptionPlan.FREE &&
- subscription.plan !== useUserStore.getState().user?.subscription.plan
+ subscription.plan !== useUserStore.getState().user?.subscription?.plan
) {
PremiumService.subscriptions.clear();
useUserStore.setState({
diff --git a/apps/mobile/app/hooks/use-pricing-plans.ts b/apps/mobile/app/hooks/use-pricing-plans.ts
index 5c3284a5c..dc0e8b4d5 100644
--- a/apps/mobile/app/hooks/use-pricing-plans.ts
+++ b/apps/mobile/app/hooks/use-pricing-plans.ts
@@ -16,12 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import {
- Plan,
- SKUResponse,
- SubscriptionPlan,
- SubscriptionPlanId
-} from "@notesnook/core";
+import { Plan, SubscriptionPlan, SubscriptionPlanId } from "@notesnook/core";
import { useEffect, useState } from "react";
import { Platform } from "react-native";
import Config from "react-native-config";
@@ -99,10 +94,7 @@ const pricingPlans: PricingPlan[] = [
description: "Unlocks essential features for personal use",
subscriptionSkuList: [
"notesnook.essential.monthly",
- "notesnook.essential.yearly",
- // no trial
- "notesnook.essential.monthly.nt",
- "notesnook.essential.yearly.nt"
+ "notesnook.essential.yearly"
],
trialSupported: true,
productSkuList: []
@@ -115,14 +107,7 @@ const pricingPlans: PricingPlan[] = [
"notesnook.pro.monthly",
"notesnook.pro.yearly",
"notesnook.pro.yearly.tier2",
- "notesnook.pro.yearly.tier3",
- // no trial
- "notesnook.pro.monthly.nt",
- "notesnook.pro.yearly.nt",
- "notesnook.pro.monthly.tier2.nt",
- "notesnook.pro.yearly.tier2.nt",
- "notesnook.pro.monthly.tier3.nt",
- "notesnook.pro.yearly.tier3.nt"
+ "notesnook.pro.yearly.tier3"
],
productSkuList: ["notesnook.pro.5year"],
trialSupported: true,
@@ -134,10 +119,7 @@ const pricingPlans: PricingPlan[] = [
description: "Become a believer and support the project",
subscriptionSkuList: [
"notesnook.believer.monthly",
- "notesnook.believer.yearly",
- // no trial
- "notesnook.believer.monthly.nt",
- "notesnook.believer.yearly.nt"
+ "notesnook.believer.yearly"
],
productSkuList: ["notesnook.believer.5year"],
trialSupported: true
@@ -188,7 +170,6 @@ const usePricingPlans = (options?: PricingPlansOptions) => {
const [cancelPromo, setCancelPromo] = useState(false);
const [userCanRequestTrial, setUserCanRequestTrial] = useState(false);
const [webPricingPlans, setWebPricingPlans] = useState<Plan[]>([]);
- const [regionalDiscount, setRegionalDiscount] = useState<SKUResponse>();
const getProduct = (planId: string, skuId: string) => {
if (isGithubRelease)
@@ -680,62 +661,19 @@ const usePricingPlans = (options?: PricingPlansOptions) => {
);
};
- // const getPricingPhases = (product: RNIap.Subscription) => {
- // if (!product) return null;
-
- // if (Platform.OS === "android") {
- // const offer = (product as RNIap.SubscriptionAndroid)
- // ?.subscriptionOfferDetails?.[0];
-
- // return offer.pricingPhases?.pricingPhaseList?.map((phase, index) => {
-
- // return {
- // localizedPrice: phase.formattedPrice,
- // price: parseInt(phase.priceAmountMicros) / 1000000,
- // monthlyFormattedPrice: getPrice(product, index, offer?.pricingPhases?.pricingPhaseList?.[1].billingPeriod.endsWith("Y"),
- // }
- // })
- // } else {
- // return (product as RNIap.SubscriptionIOS)?.pricingPhases;
- // }
-
- // }
-
- useEffect(() => {
- db.pricing
- .sku(
- isGithubRelease
- ? "paddle"
- : Platform.OS === "android"
- ? "google"
- : "apple",
- selectedProductSku.includes("5")
- ? "5-year"
- : selectedProductSku.includes("year")
- ? "yearly"
- : "monthly",
- currentPlan as SubscriptionPlanId
- )
- .then((sku) => setRegionalDiscount(sku))
- .catch((e) => console.log(e));
- }, [currentPlan, selectedProductSku]);
-
async function getRegionalDiscount(plan: string, productId: string) {
+ if (productId !== "notesnook.pro.yearly") {
+ return;
+ }
try {
return await db.pricing.sku(
- isGithubRelease
- ? "paddle"
- : Platform.OS === "android"
- ? "google"
- : "apple",
- productId.includes("5")
- ? "5-year"
- : productId.includes("year")
- ? "yearly"
- : "monthly",
+ Platform.OS === "android" ? "google" : "apple",
+ "yearly",
plan as SubscriptionPlanId
);
- } catch (e) {}
+ } catch (e) {
+ console.log(e);
+ }
}
return {
@@ -744,12 +682,17 @@ const usePricingPlans = (options?: PricingPlansOptions) => {
getStandardPrice: getLocalizedPrice,
loadingPlans,
loading,
- selectPlan: (planId: string) => {
+ selectPlan: (planId: string, productId?: string) => {
setCurrentPlan(planId);
- const product = plans.find((p) => p.id === planId)
- ?.subscriptionSkuList?.[0];
- if (product) {
- setSelectedProductSku(product);
+ if (productId) {
+ console.log(productId, "productId");
+ setSelectedProductSku(productId);
+ } else {
+ const product = plans.find((p) => p.id === planId)
+ ?.subscriptionSkuList?.[0];
+ if (product) {
+ setSelectedProductSku(product);
+ }
}
setIsPromoOffer(false);
@@ -787,10 +730,10 @@ const usePricingPlans = (options?: PricingPlansOptions) => {
(plan) => plan.plan === planIndex && plan.period === period
);
},
- regionalDiscount,
getRegionalDiscount,
isGithubRelease: isGithubRelease,
- isSubscribed: () => user?.subscription.plan !== SubscriptionPlan.FREE
+ isSubscribed: () => user?.subscription?.plan !== SubscriptionPlan.FREE,
+ finish: () => options?.onBuy?.()
};
};
diff --git a/apps/mobile/app/screens/settings/logout.ts b/apps/mobile/app/screens/settings/logout.ts
index 9b0b63051..8ca2cd11f 100644
--- a/apps/mobile/app/screens/settings/logout.ts
+++ b/apps/mobile/app/screens/settings/logout.ts
@@ -60,8 +60,9 @@ export async function logoutUser() {
}. ${strings.failedToTakeBackupMessage()}?`,
positiveText: strings.yes(),
negativeText: strings.no(),
- positivePress: () => {
+ positivePress: async () => {
resolve(true);
+ return true;
},
onClose: () => {
resolve(false);
diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsx
index ca2a48fb5..7f10ca0cc 100644
--- a/apps/mobile/app/screens/settings/settings-data.tsx
+++ b/apps/mobile/app/screens/settings/settings-data.tsx
@@ -18,7 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { formatBytes } from "@notesnook/common";
-import { SubscriptionPlan, SubscriptionStatus, User } from "@notesnook/core";
+import {
+ SubscriptionPlan,
+ SubscriptionProvider,
+ SubscriptionStatus,
+ User
+} from "@notesnook/core";
import { strings } from "@notesnook/intl";
import notifee from "@notifee/react-native";
import Clipboard from "@react-native-clipboard/clipboard";
@@ -29,7 +34,7 @@ import { getVersion } from "react-native-device-info";
import * as RNIap from "react-native-iap";
import { enabled } from "react-native-privacy-snapshot";
import ScreenGuardModule from "react-native-screenguard";
-import { db } from "../../common/database";
+import { DatabaseLogger, db } from "../../common/database";
import filesystem from "../../common/filesystem";
import { presentDialog } from "../../components/dialog/functions";
import { AppLockPassword } from "../../components/dialogs/applock-password";
@@ -92,11 +97,21 @@ export const settingsGroups: SettingSection[] = [
const user = useUserStore.getState().user;
if (!user) return;
const subscriptionProviderInfo =
- strings.subscriptionProviderInfo[user?.subscription.provider];
- presentSheet({
- title: subscriptionProviderInfo.title(),
- paragraph: subscriptionProviderInfo.desc()
- });
+ strings.subscriptionProviderInfo[user?.subscription?.provider];
+
+ if (
+ user.subscription?.provider === SubscriptionProvider.GOOGLE ||
+ user.subscription?.provider === SubscriptionProvider.APPLE
+ ) {
+ RNIap.deepLinkToSubscriptions({
+ sku: user?.subscription.productId
+ });
+ } else {
+ presentSheet({
+ title: subscriptionProviderInfo.title(),
+ paragraph: subscriptionProviderInfo.desc()
+ });
+ }
},
description: (current) => {
const user = current as User;
@@ -143,7 +158,7 @@ export const settingsGroups: SettingSection[] = [
},
useHook: () =>
useUserStore(
- (state) => state.user?.subscription.plan === SubscriptionPlan.FREE
+ (state) => state.user?.subscription?.plan === SubscriptionPlan.FREE
),
icon: "gift",
modifer: () => {
@@ -423,6 +438,7 @@ export const settingsGroups: SettingSection[] = [
paragraph: strings.deleteAccountDesc(),
positiveType: "errorShade",
input: true,
+ secureTextEntry: true,
inputPlaceholder: strings.enterAccountPassword(),
positiveText: strings.delete(),
positivePress: async (value) => {
@@ -430,16 +446,28 @@ export const settingsGroups: SettingSection[] = [
const verified = await db.user?.verifyPassword(value);
if (verified) {
setTimeout(async () => {
- startProgress({
- title: "Deleting account",
- paragraph: "Please wait while we delete your account"
- });
- Navigation.navigate("Notes");
- await db.user?.deleteUser(value);
- await BiometricService.resetCredentials();
- SettingsService.set({
- introCompleted: true
- });
+ try {
+ startProgress({
+ title: "Deleting account",
+ paragraph:
+ "Please wait while we delete your account"
+ });
+ await db.user?.deleteUser(value);
+ DatabaseLogger.info("User account deleted");
+ Navigation.navigate("Notes");
+ await BiometricService.resetCredentials();
+ SettingsService.set({
+ introCompleted: true
+ });
+ } catch (e) {
+ endProgress();
+ DatabaseLogger.error(e);
+ ToastManager.error(
+ e as Error,
+ strings.failedToDeleteAccount(),
+ "global"
+ );
+ }
}, 300);
} else {
ToastManager.show({
@@ -448,11 +476,7 @@ export const settingsGroups: SettingSection[] = [
context: "global"
});
}
-
- endProgress();
} catch (e) {
- endProgress();
-
ToastManager.error(
e as Error,
strings.failedToDeleteAccount(),
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index 77e6d035d..03a26dfdc 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -5968,6 +5968,10 @@ msgstr "Source code"
msgid "Spaces"
msgstr "Spaces"
+#: src/strings.ts:2588
+msgid "Special Offer"
+msgstr "Special Offer"
+
#: src/strings.ts:2125
msgid "Spell check"
msgstr "Spell check"
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index 3c7eedcce..7eadc28f7 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -5934,6 +5934,10 @@ msgstr ""
msgid "Spaces"
msgstr ""
+#: src/strings.ts:2588
+msgid "Special Offer"
+msgstr ""
+
#: src/strings.ts:2125
msgid "Spell check"
msgstr ""
diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.ts
index 692822a00..b0de22511 100644
--- a/packages/intl/src/strings.ts
+++ b/packages/intl/src/strings.ts
@@ -2584,5 +2584,6 @@ Use this if changes from other devices are not appearing on this device. This wi
changePlan: () => t`Change plan`,
contactSupportToChangePlan: () =>
t`You have made a one time purchase. To change your plan please contact support.`,
- alreadySubscribed: () => t`You are already subscribed to this plan.`
+ alreadySubscribed: () => t`You are already subscribed to this plan.`,
+ specialOffer: () => t`Special Offer`
};