Skip to content

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

minor refactoring

Ammar Ahmed29f741e5db5d
diff --git a/apps/mobile/AppRootEvents.js b/apps/mobile/AppRootEvents.js
index cea05b43a..20b5e066d 100644
--- a/apps/mobile/AppRootEvents.js
+++ b/apps/mobile/AppRootEvents.js
@@ -335,7 +335,6 @@ export const AppRootEvents = React.memo(
if (user) {
setUser(user);
clearMessage();
- await PremiumService.setPremiumStatus();
attachIAPListeners();
await Sync.run();
@@ -355,7 +354,6 @@ export const AppRootEvents = React.memo(
}
setUser(user);
} else {
- await PremiumService.setPremiumStatus();
setLoginMessage();
}
} catch (e) {
@@ -368,6 +366,7 @@ export const AppRootEvents = React.memo(
console.log('unknown error', e);
}
} finally {
+ await PremiumService.setPremiumStatus();
isUserReady = true;
if (login) {
eSendEvent(eCloseProgressDialog);
diff --git a/apps/mobile/src/components/Dialog/index.js b/apps/mobile/src/components/Dialog/index.js
index 104cc7d43..56b1efbc9 100644
--- a/apps/mobile/src/components/Dialog/index.js
+++ b/apps/mobile/src/components/Dialog/index.js
@@ -1,15 +1,13 @@
-import React, {Component} from 'react';
-import {View} from 'react-native';
-import {Actions} from '../../provider/Actions';
+import React, { Component } from 'react';
+import { View } from 'react-native';
import { useSelectionStore, useTrashStore } from '../../provider/stores';
-import {DDS} from '../../services/DeviceDetection';
-import {ToastEvent} from '../../services/EventManager';
-import {getElevation, history} from '../../utils';
-import {db} from '../../utils/DB';
+import { DDS } from '../../services/DeviceDetection';
+import { ToastEvent } from '../../services/EventManager';
+import { getElevation, history } from '../../utils';
+import { db } from '../../utils/DB';
import { deleteItems } from '../../utils/functions';
-import {ph, pv} from '../../utils/SizeUtils';
-import {dialogActions} from '../DialogManager/DialogActions';
-import {updateEvent} from '../DialogManager/recievers';
+import { ph, pv } from '../../utils/SizeUtils';
+import { dialogActions } from '../DialogManager/DialogActions';
import Seperator from '../Seperator';
import BaseDialog from './base-dialog';
import DialogButtons from './dialog-buttons';
diff --git a/apps/mobile/src/components/Premium/PremiumComponent.js b/apps/mobile/src/components/Premium/PremiumComponent.js
index 0fe77d547..af65fd63e 100644
--- a/apps/mobile/src/components/Premium/PremiumComponent.js
+++ b/apps/mobile/src/components/Premium/PremiumComponent.js
@@ -119,6 +119,7 @@ export const PremiumComponent = ({close, promo}) => {
let _user = await db.user.getUser();
setUser(_user);
let products = PremiumService.getProducts();
+
if (products.length > 0) {
let offers = {
monthly: products.find(
@@ -175,7 +176,7 @@ export const PremiumComponent = ({close, promo}) => {
if (!user) {
close();
setTimeout(() => {
- eSendEvent(eOpenLoginDialog,1);
+ eSendEvent(eOpenLoginDialog, 1);
}, 400);
} else {
setBuying(true);
@@ -262,7 +263,7 @@ export const PremiumComponent = ({close, promo}) => {
onPress={() => {
setProduct({
type: 'monthly',
- data: offers.monthly,
+ data: offers?.monthly,
});
}}
style={{
@@ -281,7 +282,7 @@ export const PremiumComponent = ({close, promo}) => {
onPress={() => {
setProduct({
type: 'yearly',
- data: offers.yearly,
+ data: offers?.yearly,
});
}}
style={{
diff --git a/apps/mobile/src/components/Premium/PremiumDialog.js b/apps/mobile/src/components/Premium/PremiumDialog.js
index 10cb79c3b..34b85a634 100644
--- a/apps/mobile/src/components/Premium/PremiumDialog.js
+++ b/apps/mobile/src/components/Premium/PremiumDialog.js
@@ -38,7 +38,7 @@ class PremiumDialog extends React.Component {
render() {
return !this.state.visible ? null : (
<ActionSheetWrapper onClose={this.onClose} fwdRef={this.actionSheetRef}>
- <PremiumComponent promo={this.state.promo} close={this.close} />
+ <PremiumComponent promo={this.state.promo} close={this.close} />
</ActionSheetWrapper>
);
}
diff --git a/apps/mobile/src/components/PublishNoteDialog/index.js b/apps/mobile/src/components/PublishNoteDialog/index.js
index ee4f0c33b..014be3e93 100644
--- a/apps/mobile/src/components/PublishNoteDialog/index.js
+++ b/apps/mobile/src/components/PublishNoteDialog/index.js
@@ -248,7 +248,7 @@ const PublishNoteDialog = () => {
flexShrink: 1,
}}>
<Heading size={SIZE.md}>
- Password protection {isLocked ? 'enabled' : 'disabled'}
+ Password protection
</Heading>
<Paragraph>
Published note can only be viewed by someone with the
@@ -285,7 +285,7 @@ const PublishNoteDialog = () => {
flexShrink: 1,
}}>
<Heading size={SIZE.md}>
- Self destruct {selfDestruct ? 'enabled' : 'disabled'}
+ Self destruct
</Heading>
<Paragraph>
Published note link will be automatically deleted once it is
diff --git a/apps/mobile/src/services/PremiumService.js b/apps/mobile/src/services/PremiumService.js
index a098d2737..aa6420f20 100644
--- a/apps/mobile/src/services/PremiumService.js
+++ b/apps/mobile/src/services/PremiumService.js
@@ -31,13 +31,15 @@ async function setPremiumStatus() {
userstore.setPremium(get())
userstore.setUser(user);
}
-
+ } catch (e) {
+ premiumStatus = null;
+ } finally {
+ console.log('we are here')
if (!get()) {
await RNIap.initConnection();
products = await RNIap.getSubscriptions(itemSkus);
+ console.log('products',products);
}
- } catch (e) {
- premiumStatus = null;
}
}
diff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.js
index b6b010433..14d3ce4ab 100755
--- a/apps/mobile/src/utils/index.js
+++ b/apps/mobile/src/utils/index.js
@@ -229,7 +229,7 @@ export function getTotalNotes(notebook) {
}, 0);
}
-export const itemSkus = ['com.streetwriters.notesnook.sub.mo','com.streetwriters.notesnook.sub.yr',,'com.streetwriters.notesnook.sub.yr.15','com.streetwriters.notesnook.sub.mo.15','com.streetwriters.notesnook.sub.mo.ofr']
+export const itemSkus = ['com.streetwriters.notesnook.sub.mo','com.streetwriters.notesnook.sub.yr','com.streetwriters.notesnook.sub.yr.15','com.streetwriters.notesnook.sub.mo.15','com.streetwriters.notesnook.sub.mo.ofr']
export const MenuItemsList = [
{