diff --git a/apps/mobile/App.js b/apps/mobile/App.js index 10f93fa36..66e7e6f93 100644 --- a/apps/mobile/App.js +++ b/apps/mobile/App.js @@ -28,7 +28,7 @@ import {db} from './src/utils/DB'; import {DDS} from './src/services/DeviceDetection'; import {MMKV} from './src/utils/mmkv'; import Backup from './src/services/Backup'; -import { setLoginMessage } from './src/services/Message'; +import {setLoginMessage} from './src/services/Message'; let firstLoad = true; let note = null; @@ -66,32 +66,28 @@ const App = () => { const updateTheme = async () => { let settings; - settings = await MMKV.getStringAsync('settings'); - if (settings) { - settings = JSON.parse(settings); - if (settings.useSystemTheme) { - let newColors = await getColorScheme(settings.useSystemTheme); - dispatch({type: Actions.THEME, colors: newColors}); - } + settings = await MMKV.getStringAsync('settings'); + if (settings) { + settings = JSON.parse(settings); + if (settings.useSystemTheme) { + let newColors = await getColorScheme(settings.useSystemTheme); + dispatch({type: Actions.THEME, colors: newColors}); } + } }; useEffect(() => { + let message = 'Internet connection restored'; + let type = 'success'; if (!netInfo.isConnected || !netInfo.isInternetReachable) { - db.user?.get().then((user) => { - if (user) { - ToastEvent.show('No internet connection', 'error'); - } else { - } - }); - } else { - db.user?.get().then((user) => { - if (user) { - ToastEvent.show('Internet connection restored', 'success'); - } else { - } - }); + message = 'No internet connection'; + type = 'error'; } + db.user?.get().then((user) => { + if (user) { + ToastEvent.show(message, type); + } + }); }, [netInfo]); const syncChanges = async () => { @@ -153,38 +149,37 @@ const App = () => { if (user) { dispatch({type: Actions.USER, user: user}); await startSyncer(); - } + } } catch (e) { error = e; - console.log(e) - } - if (!user || !user.id) { - setLoginMessage(dispatch); - } - dispatch({type: Actions.ALL}); - setInit(true); - backupData(); + console.log(e); + } + if (!user || !user.id) { + setLoginMessage(dispatch); + } + dispatch({type: Actions.ALL}); + setInit(true); + backupData(); - if (error) { - setTimeout(() => { - ToastEvent.show(error.message); - }, 500); - } - + if (error) { + setTimeout(() => { + ToastEvent.show(error.message); + }, 500); + } }); }, []); async function backupData() { - await sleep(1000) - settings = await MMKV.getStringAsync('settings'); - settings = JSON.parse(settings); - if (await Backup.checkBackupRequired(settings.reminder) ) { - try { - await Backup.run(); - } catch(e) { - console.log(e); - } + await sleep(1000); + settings = await MMKV.getStringAsync('settings'); + settings = JSON.parse(settings); + if (await Backup.checkBackupRequired(settings.reminder)) { + try { + await Backup.run(); + } catch (e) { + console.log(e); } + } } async function Initialize() { @@ -200,21 +195,20 @@ const App = () => { } firstLoad = false; } - settings = await MMKV.getStringAsync('settings'); - console.log('settings',settings) - if (!settings) { - settings = defaultState.settings; - await MMKV.setStringAsync('settings', JSON.stringify(settings)); - } else { - settings = JSON.parse(settings); - } - if (settings.fontScale) { - scale.fontScale = settings.fontScale; - } - dispatch({type: Actions.SETTINGS, settings: {...settings}}); - updateSize(); - await updateTheme(); - + settings = await MMKV.getStringAsync('settings'); + console.log('settings', settings); + if (!settings) { + settings = defaultState.settings; + await MMKV.setStringAsync('settings', JSON.stringify(settings)); + } else { + settings = JSON.parse(settings); + } + if (settings.fontScale) { + scale.fontScale = settings.fontScale; + } + dispatch({type: Actions.SETTINGS, settings: {...settings}}); + updateSize(); + await updateTheme(); } if (!init) { diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.js index 6d7139569..9fc9174f2 100644 --- a/apps/mobile/src/components/DialogManager/index.js +++ b/apps/mobile/src/components/DialogManager/index.js @@ -43,6 +43,7 @@ import {VaultDialog} from '../VaultDialog'; import {TEMPLATE_DELETE, TEMPLATE_PERMANANT_DELETE} from './Templates'; import {hexToRGBA} from "../../utils/ColorUtils"; import {DDS} from "../../services/DeviceDetection"; +import ResultDialog from '../ResultDialog'; export class DialogManager extends Component { constructor(props) { @@ -376,6 +377,8 @@ export class DialogManager extends Component { + + ); } diff --git a/apps/mobile/src/components/ProgressDialog/index.js b/apps/mobile/src/components/ProgressDialog/index.js index c49989fb7..1c7d70733 100644 --- a/apps/mobile/src/components/ProgressDialog/index.js +++ b/apps/mobile/src/components/ProgressDialog/index.js @@ -11,7 +11,7 @@ import {DDS} from "../../services/DeviceDetection"; const ProgressDialog = () => { const [state, dispatch] = useTracked(); - const {colors, tags, premiumUser} = state; + const {colors,} = state; const [visible, setVisible] = useState(false); const [dialogData, setDialogData] = useState({ title: 'Loading', diff --git a/apps/mobile/src/components/RecoveryKeyDialog/index.js b/apps/mobile/src/components/RecoveryKeyDialog/index.js index 269698d4b..92163edd7 100644 --- a/apps/mobile/src/components/RecoveryKeyDialog/index.js +++ b/apps/mobile/src/components/RecoveryKeyDialog/index.js @@ -5,11 +5,12 @@ import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import RNFetchBlob from 'rn-fetch-blob'; import {LOGO_BASE64} from '../../assets/images/assets'; import { + eSendEvent, eSubscribeEvent, eUnSubscribeEvent, ToastEvent, } from '../../services/EventManager'; -import {eOpenRecoveryKeyDialog} from '../../utils/Events'; +import {eOpenRecoveryKeyDialog, eOpenResultDialog} from '../../utils/Events'; import {dWidth} from '../../utils'; import ActionSheet from '../ActionSheet'; import {Button} from '../Button'; @@ -27,14 +28,28 @@ class RecoveryKeyDialog extends React.Component { this.actionSheetRef = createRef(); this.svg = createRef(); this.user; + this.signup = false; } - open = () => { + open = (signup) => { + if (signup) { + this.signup = true; + } this.actionSheetRef.current?._setModalVisible(true); }; close = () => { this.actionSheetRef.current?._setModalVisible(false); + if (!this.signup) { + setTimeout(() => { + eSendEvent(eOpenResultDialog, { + title: 'Welcome!', + paragraph: 'Your 14 day trial for Notesnook Pro is activated', + icon: 'checkbox-marked-circle', + button: 'Thank You!', + }); + }, 500); + } }; async componentDidMount() { eSubscribeEvent(eOpenRecoveryKeyDialog, this.open); @@ -113,6 +128,7 @@ class RecoveryKeyDialog extends React.Component { alignSelf: 'center', borderRadius: 10, }} + closeOnTouchBackdrop={false} onOpen={this.onOpen} ref={this.actionSheetRef} initialOffsetFromBottom={1}> @@ -233,7 +249,13 @@ class RecoveryKeyDialog extends React.Component { data or reset your password using this recovery key. - + +