Skip to content

Commit

Permalink
fix pro version is not getting restored bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kamalkishor1991 committed Mar 16, 2024
1 parent b3cb72f commit 7f0bc22
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions libs/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions screens/ProVersionScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default function ProScreen() {
<View>
<Text style={styles.title}>{t('Pro benefits')}</Text>
<Text style={[styles.line]}>{t('1. Add more than 4 colors in a palette 🎨')}</Text>
<Text style={[styles.line]}>{t('2. Export/sync colors to private github repository')}</Text>
<CromaButton
style={{ backgroundColor: '#ff5c59' }}
textStyle={{ color: '#fff' }}
Expand All @@ -37,10 +36,11 @@ export default function ProScreen() {
</CromaButton>
<Text style={styles.line}>
{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 😊'"
)}
</Text>
<CromaButton onPress={purchaseDevelopment}>{t('Buy me a coffee ☕')}</CromaButton>
<Text style={styles.line}>{t("3. Help us keep the app open source'")}</Text>
<CromaButton onPress={purchaseDevelopment}>{t('Support development')}</CromaButton>

{!isPro && (
<View>
Expand Down
4 changes: 2 additions & 2 deletions store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7f0bc22

Please sign in to comment.