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
add delete account dialog
ammarahm-ed01712eb9e816
diff --git a/apps/mobile/App.js b/apps/mobile/App.jsindex 2301c285b..7e1bf3b81 100644--- a/apps/mobile/App.js+++ b/apps/mobile/App.js@@ -1,41 +1,47 @@import * as NetInfo from '@react-native-community/netinfo';-import { EV } from 'notes-core/common';-import React, { useEffect } from 'react';+import {EV} from 'notes-core/common';+import React, {useEffect} from 'react';import {Appearance,AppState,Linking,NativeModules,Platform,- StatusBar+ StatusBar,} from 'react-native';import * as RNIap from 'react-native-iap';-import { enabled } from 'react-native-privacy-snapshot';-import { SafeAreaProvider } from 'react-native-safe-area-context';+import {enabled} from 'react-native-privacy-snapshot';+import {SafeAreaProvider} from 'react-native-safe-area-context';import SplashScreen from 'react-native-splash-screen';-import { RootView } from './initializer.root';-import { useTracked } from './src/provider';-import { Actions } from './src/provider/Actions';+import {RootView} from './initializer.root';+import {useTracked} from './src/provider';+import {Actions} from './src/provider/Actions';import Backup from './src/services/Backup';-import { DDS } from './src/services/DeviceDetection';+import {DDS} from './src/services/DeviceDetection';import {eSendEvent,eSubscribeEvent,- eUnSubscribeEvent+ eUnSubscribeEvent,} from './src/services/EventManager';import IntentService from './src/services/IntentService';import {clearMessage,setEmailVerifyMessage,- setLoginMessage+ setLoginMessage,} from './src/services/Message';import Navigation from './src/services/Navigation';import PremiumService from './src/services/PremiumService';import SettingsService from './src/services/SettingsService';import Sync from './src/services/Sync';-import { editing, getAppIsIntialized, getIntentOnAppLoadProcessed, setAppIsInitialized, setIntentOnAppLoadProcessed } from './src/utils';-import { COLOR_SCHEME } from './src/utils/Colors';-import { db } from './src/utils/DB';+import {+ editing,+ getAppIsIntialized,+ getIntentOnAppLoadProcessed,+ setAppIsInitialized,+ setIntentOnAppLoadProcessed,+} from './src/utils';+import {COLOR_SCHEME} from './src/utils/Colors';+import {db} from './src/utils/DB';import {eClosePremiumDialog,eCloseProgressDialog,@@ -45,12 +51,12 @@ import {eOpenPendingDialog,eOpenProgressDialog,eOpenSideMenu,- refreshNotesPage+ refreshNotesPage,} from './src/utils/Events';-import { MMKV } from './src/utils/mmkv';-import { tabBarRef } from './src/utils/Refs';-import { sleep } from './src/utils/TimeUtils';-import { getNote, setIntent } from './src/views/Editor/Functions';+import {MMKV} from './src/utils/mmkv';+import {tabBarRef} from './src/utils/Refs';+import {sleep} from './src/utils/TimeUtils';+import {getNote, setIntent} from './src/views/Editor/Functions';const {ReceiveSharingIntent} = NativeModules;let Sentry = null;@@ -72,7 +78,7 @@ const onAppStateChanged = async (state) => {updateStatusBarColor();if (SettingsService.get().privacyScreen) {enabled(false);- }+ }if (getAppIsIntialized()) {await MMKV.removeItem('appState');}@@ -203,7 +209,9 @@ const App = () => {IntentService.setIntent(intent);IntentService.check(loadIntent);}- } else if (url.startsWith('https://app.notesnook.com/account/verified')) {+ } else if (+ url.startsWith('https://app.notesnook.com/account/verified')+ ) {await onEmailVerified();} else {return;@@ -269,10 +277,13 @@ const App = () => {};const onLogout = (reason) => {- console.log(reason, 'REASON');+ dispatch({type: Actions.USER, user: null});+ dispatch({type: Actions.CLEAR_ALL});+ dispatch({type: Actions.SYNCING, syncing: false});+ setLoginMessage(dispatch);eSendEvent(eOpenProgressDialog, {- title: 'User Logged Out',- paragraph: 'You have been logged out of your account.',+ title: reason ? reason : 'User Logged Out',+ paragraph: `You have been logged out of your account.`,action: async () => {eSendEvent(eCloseProgressDialog);await sleep(50);@@ -314,7 +325,7 @@ const App = () => {await onEmailVerified();}});- setIntentOnAppLoadProcessed(true)+ setIntentOnAppLoadProcessed(true);sleep(300).then(() => eSendEvent(eOpenSideMenu));//Sentry = require('@sentry/react-native');// Sentry.init({@@ -347,7 +358,7 @@ const App = () => {IntentService.check((event) => {SplashScreen.hide();loadIntent(event);- setIntentOnAppLoadProcessed(true)+ setIntentOnAppLoadProcessed(true);dispatch({type: Actions.ALL});isIntent = true;dispatch({type: Actions.INTENT_MODE, state: true});@@ -359,7 +370,7 @@ const App = () => {if (!isIntent) {dispatch({type: Actions.INTENT_MODE, state: false});ReceiveSharingIntent.clearFileNames();- setIntentOnAppLoadProcessed(true)+ setIntentOnAppLoadProcessed(true);loadMainApp();}});diff --git a/apps/mobile/src/components/Dialog/DialogHeader.js b/apps/mobile/src/components/Dialog/DialogHeader.jsindex 9c2b8b030..4c1a2afea 100644--- a/apps/mobile/src/components/Dialog/DialogHeader.js+++ b/apps/mobile/src/components/Dialog/DialogHeader.js@@ -6,7 +6,7 @@ import {Button} from '../Button';import Heading from '../Typography/Heading';import Paragraph from '../Typography/Paragraph';-const DialogHeader = ({icon, title, paragraph, button}) => {+const DialogHeader = ({icon, title, paragraph, button,paragraphColor}) => {const [state, dispatch] = useTracked();const colors = state.colors;@@ -45,7 +45,7 @@ const DialogHeader = ({icon, title, paragraph, button}) => {</View>{paragraph ? (- <Paragraph color={colors.icon}>{paragraph}</Paragraph>+ <Paragraph color={paragraphColor || colors.icon}>{paragraph}</Paragraph>) : null}</View></View>diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.jsindex 61a23bc54..95666c23e 100644--- a/apps/mobile/src/views/Settings/index.js+++ b/apps/mobile/src/views/Settings/index.js@@ -17,9 +17,11 @@ import BaseDialog from '../../components/Dialog/base-dialog';import DialogButtons from '../../components/Dialog/dialog-buttons';import DialogContainer from '../../components/Dialog/dialog-container';import DialogHeader from '../../components/Dialog/dialog-header';+import Input from '../../components/Input';import {PressableButton} from '../../components/PressableButton';import Seperator from '../../components/Seperator';import {ListHeaderComponent} from '../../components/SimpleList/ListHeaderComponent';+import {Toast} from '../../components/Toast';import Heading from '../../components/Typography/Heading';import Paragraph from '../../components/Typography/Paragraph';import {useTracked} from '../../provider';@@ -206,17 +208,19 @@ const SectionHeader = ({title}) => {textAlignVertical: 'center',paddingHorizontal: 12,height: 30,- backgroundColor:colors.nav+ backgroundColor: colors.nav,}}>{title}</Heading>);};+let passwordValue = null;const AccoutLogoutSection = () => {const [state, dispatch] = useTracked();const {colors, user} = state;const [visible, setVisible] = useState(false);+ const [deleteAccount, setDeleteAccount] = useState(true);return (user && (@@ -234,16 +238,82 @@ const AccoutLogoutSection = () => {onPressNegative={() => setVisible(false)}onPressPositive={async () => {await db.user.logout();- dispatch({type: Actions.USER, user: null});- dispatch({type: Actions.CLEAR_ALL});- dispatch({type: Actions.SYNCING, syncing: false});- setLoginMessage(dispatch);setVisible(false);}}/></DialogContainer></BaseDialog>)}++ {deleteAccount && (+ <BaseDialog+ onRequestClose={() => {+ setDeleteAccount(false);+ passwordValue = null;+ }}+ visible={true}>+ <DialogContainer>+ <DialogHeader+ title="Delete Account"+ paragraph="All your data will be removed permanantly. This action is IRREVERSIBLE."+ paragraphColor={colors.red}+ />++ <Input+ placeholder="Enter Account Password"+ onChangeText={(v) => {+ passwordValue = v;+ }}+ secureTextEntry={true}+ />++ <View+ style={{+ flexDirection: 'row',+ alignItems: 'center',+ alignSelf: 'flex-end',+ }}>+ <Button+ onPress={() => {+ setDeleteAccount(false);+ passwordValue = null;+ }}+ fontSize={SIZE.md}+ type="gray"+ title="Cancel"+ />+ <Button+ onPress={async () => {+ if (!passwordValue) {+ ToastEvent.show(+ 'Account Password Required.',+ 'error',+ 'local',+ );+ return;+ }+ try {+ await db.user.deleteUser(passwordValue);+ } catch (e) {+ ToastEvent.show(e.message, 'error', 'local');+ }+ close();+ }}+ fontSize={SIZE.md}+ style={{+ marginLeft: 10,+ }}+ type="accent"+ accentColor="light"+ accentText="red"+ title="Delete"+ />+ </View>+ </DialogContainer>+ <Toast context="local" />+ </BaseDialog>+ )}+{[{name: 'Logout',@@ -253,6 +323,10 @@ const AccoutLogoutSection = () => {},{name: 'Delete My Account',+ func: () => {+ setDeleteAccount(true);+ passwordValue = null;+ },},].map((item, index) => (<PressableButton