A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix multiple subscription for dispatch event
ammarahm-eda1c4cb980559
diff --git a/apps/mobile/App.js b/apps/mobile/App.jsindex cb3066468..80e8640f8 100644--- a/apps/mobile/App.js+++ b/apps/mobile/App.js@@ -40,13 +40,9 @@ const App = () => {}, []);useEffect(() => {- eSubscribeEvent(eDispatchAction, (type) => {- dispatch(type);- });+ eSubscribeEvent(eDispatchAction, dispatch);return () => {- eUnSubscribeEvent(eDispatchAction, (type) => {- dispatch(type);- });+ eUnSubscribeEvent(eDispatchAction, dispatch);};}, []);diff --git a/apps/mobile/AppRootEvents.js b/apps/mobile/AppRootEvents.jsindex 4bd41ad0c..6d0d089c8 100644--- a/apps/mobile/AppRootEvents.js+++ b/apps/mobile/AppRootEvents.js@@ -123,9 +123,6 @@ export const AppRootEvents = React.memo(}).catch(console.log);- eSubscribeEvent(eDispatchAction, (type) => {- dispatch(type);- });attachIAPListeners();AppState.addEventListener('change', onAppStateChanged);Appearance.addChangeListener(SettingsService.setTheme);@@ -152,12 +149,12 @@ export const AppRootEvents = React.memo(EV.unsubscribe(EVENTS.databaseSyncRequested, partialSync);EV.unsubscribe(EVENTS.userLoggedOut, onLogout);EV.unsubscribe(EVENTS.userEmailConfirmed, onEmailVerified);- EV.unsubscribe(EVENTS.userCheckStatus, PremiumService.onUserStatusCheck);+ EV.unsubscribe(+ EVENTS.userCheckStatus,+ PremiumService.onUserStatusCheck,+ );EV.unsubscribe(EVENTS.userSubscriptionUpdated, onAccountStatusChange);- eUnSubscribeEvent(eDispatchAction, (type) => {- dispatch(type);- });AppState.removeEventListener('change', onAppStateChanged);Appearance.removeChangeListener(SettingsService.setTheme);Linking.removeEventListener('url', onUrlRecieved);@@ -165,6 +162,8 @@ export const AppRootEvents = React.memo(};}, [loading]);++const onSyncComplete = async () => {dispatch({type: Actions.ALL});dispatch({type: Actions.LAST_SYNC, lastSync: await db.lastSynced()});@@ -216,11 +215,12 @@ export const AppRootEvents = React.memo(});};- const onAccountStatusChange = async () => {-- await PremiumService.setPremiumStatus();- let user = await db.user.getUser();- if (user.subscription.type === 5) {+ const onAccountStatusChange = async (userStatus) => {+ console.log('STATUS CODE', userStatus);++ if (!PremiumService.get() && userStatus.type === 5) {++ console.log('STATUS CODE IN', userStatus.type);eSendEvent(eOpenProgressDialog, {title: 'Notesnook Pro',paragraph: `Your Notesnook Pro subscription has been successfully activated.`,@@ -232,6 +232,7 @@ export const AppRootEvents = React.memo(noProgress: true,});}+ await PremiumService.setPremiumStatus();};const partialSync = async () => {@@ -260,7 +261,7 @@ export const AppRootEvents = React.memo(eSendEvent(eOpenLoginDialog);},icon: 'logout',- actionText: 'Login Again',+ actionText: 'Relogin',noProgress: true,});};