From 7f0bc2219975074238541beffcc53d0803f7b080 Mon Sep 17 00:00:00 2001 From: Kamal Joshi Date: Sat, 16 Mar 2024 10:53:21 +0530 Subject: [PATCH] fix pro version is not getting restored bug --- libs/Helpers.js | 6 ++++-- screens/ProVersionScreen.js | 6 +++--- store/store.js | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libs/Helpers.js b/libs/Helpers.js index 4f591027..f1d1bf07 100644 --- a/libs/Helpers.js +++ b/libs/Helpers.js @@ -40,13 +40,15 @@ const purchase = async function (setPurchase, productSKU) { logEvent('purchase_failed'); } }; -const initPurchase = async function (setPurchase) { +const initPurchase = async function (setPurchase, showMessage = true) { const productSKU = productSku(); try { let products = await getAvailablePurchases(); if (products.find((product) => product.productId === productSKU)) { await setPurchase(products.find((product) => product.productId === productSKU)); - notifyMessage('Congrats, You are already a pro user!'); + if (showMessage) { + notifyMessage('Congrats, You are already a pro user!'); + } } } catch (e) { notifyMessage('Failed during initialization of purchase: ' + e); diff --git a/screens/ProVersionScreen.js b/screens/ProVersionScreen.js index 83748642..13a70739 100644 --- a/screens/ProVersionScreen.js +++ b/screens/ProVersionScreen.js @@ -28,7 +28,6 @@ export default function ProScreen() { {t('Pro benefits')} {t('1. Add more than 4 colors in a palette 🎨')} - {t('2. Export/sync colors to private github repository')} {t( - "3. Support the development efforts to keep the app awesome and simple without any ads and annoying notifications 😊'" + "2. Support the development efforts to keep the app awesome and simple without any ads and annoying notifications 😊'" )} - {t('Buy me a coffee ☕')} + {t("3. Help us keep the app open source'")} + {t('Support development')} {!isPro && ( diff --git a/store/store.js b/store/store.js index a72a487b..e8dca8e4 100644 --- a/store/store.js +++ b/store/store.js @@ -33,12 +33,12 @@ export default function useApplicationHook() { setState((state) => ({ ...state, isLoading: true })); const isUserAlreadyExits = await Storage.checkUserAlreadyExists(); if (isUserAlreadyExits != 'true') { - // For first time user check if user is pro or not. - Platform.OS === 'android' && (await initPurchase(setPurchase)); // IF USER IS COMING FIRST TIME await Storage.setUserAlreadyExists(); await Storage.setUserDeviceId(); } + Platform.OS === 'android' && + (await initPurchase(setPurchase, /* showMessage=*/ !isUserAlreadyExits)); const allPalettes = await loadPlalettes(); setState((state) => ({ ...state, allPalettes, isLoading: false })); setStoreLoaded(true);