diff --git a/apps/mobile/App.js b/apps/mobile/App.js index 8be824fbe..589a66b09 100644 --- a/apps/mobile/App.js +++ b/apps/mobile/App.js @@ -17,13 +17,10 @@ import { eUnSubscribeEvent, } from './src/services/EventManager'; import SettingsService from './src/services/SettingsService'; -import { editing } from './src/utils'; import {db} from './src/utils/DB'; import {eDispatchAction, eOpenSideMenu} from './src/utils/Events'; import {MMKV} from './src/utils/mmkv'; -import { tabBarRef } from './src/utils/Refs'; import EditorRoot from './src/views/Editor/EditorRoot'; -import { setNoteOnly } from './src/views/Editor/Functions'; let initStatus = false; const App = () => { @@ -48,9 +45,11 @@ const App = () => { eSendEvent(eOpenSideMenu); SplashScreen.hide(); await db.init(); + console.log('db is ready'); let requireIntro = await MMKV.getItem('introCompleted'); + loadDefaultNotes(); + console.log('loaded default note'); if (!requireIntro) { - await loadDefaultNotes(); await MMKV.setItem( 'askForRating', JSON.stringify({ @@ -86,7 +85,7 @@ const App = () => { })(); }, []); - const _dispatch = (data) => { + const _dispatch = data => { dispatch(data); }; @@ -98,6 +97,7 @@ const App = () => { }, []); const loadMainApp = () => { + console.log('status on init', initStatus); if (initStatus) { SettingsService.setAppLoaded(); eSendEvent('load_overlay'); @@ -107,6 +107,7 @@ const App = () => { async function loadDefaultNotes() { try { + console.log('creating note'); const isCreated = await MMKV.getItem('defaultNoteCreated'); if (isCreated) return; const notes = await http.get( @@ -114,6 +115,7 @@ const App = () => { ); if (!notes) return; for (let note of notes) { + console.log('getting content'); const content = await http.get(note.mobileContent); await db.notes.add({ title: note.title, @@ -122,9 +124,11 @@ const App = () => { content: {type: 'tiny', data: content}, }); } + console.log('default note created'); await MMKV.setItem('defaultNoteCreated', 'yes'); + dispatch({type: Actions.ALL}); } catch (e) { - console.log(e); + console.log(e, 'loading note on welcome'); } } diff --git a/apps/mobile/initializer.root.js b/apps/mobile/initializer.root.js index fe8a80f59..32db59f88 100644 --- a/apps/mobile/initializer.root.js +++ b/apps/mobile/initializer.root.js @@ -83,7 +83,7 @@ export const RootView = React.memo( - + ); }, diff --git a/apps/mobile/src/components/AppLoader/index.js b/apps/mobile/src/components/AppLoader/index.js index d7f65bf82..74152712a 100644 --- a/apps/mobile/src/components/AppLoader/index.js +++ b/apps/mobile/src/components/AppLoader/index.js @@ -1,22 +1,22 @@ -import React, {useEffect, useState} from 'react'; -import {View} from 'react-native'; -import Animated, {Easing} from 'react-native-reanimated'; +import React, { useEffect, useState } from 'react'; +import { View } from 'react-native'; +import Animated, { Easing } from 'react-native-reanimated'; import AnimatedProgress from 'react-native-reanimated-progress-bar'; -import {useTracked} from '../../provider'; -import {Actions} from '../../provider/Actions'; +import { useTracked } from '../../provider'; +import { Actions } from '../../provider/Actions'; import { eSendEvent, eSubscribeEvent, - eUnSubscribeEvent, + eUnSubscribeEvent } from '../../services/EventManager'; -import {editing} from '../../utils'; -import {changeContainerScale, ContainerScale} from '../../utils/Animations'; -import {db} from '../../utils/DB'; -import {eOpenRateDialog, eOpenSideMenu} from '../../utils/Events'; -import {MMKV} from '../../utils/mmkv'; -import {tabBarRef} from '../../utils/Refs'; -import {sleep} from '../../utils/TimeUtils'; -import {setNoteOnly} from '../../views/Editor/Functions'; +import { editing } from '../../utils'; +import { changeContainerScale, ContainerScale } from '../../utils/Animations'; +import { db } from '../../utils/DB'; +import { eOpenRateDialog, eOpenSideMenu } from '../../utils/Events'; +import { MMKV } from '../../utils/mmkv'; +import { tabBarRef } from '../../utils/Refs'; +import { sleep } from '../../utils/TimeUtils'; +import SplashScreen from '../SplashScreen'; const scaleV = new Animated.Value(0.95); const opacityV = new Animated.Value(1); @@ -27,6 +27,7 @@ const AppLoader = ({onLoad}) => { const [opacity, setOpacity] = useState(true); const load = async value => { + console.log('loading called here'); if (value === 'hide') { setLoading(true); opacityV.setValue(1); @@ -34,7 +35,6 @@ const AppLoader = ({onLoad}) => { } let appState = await MMKV.getItem('appState'); if (appState) { - appState = JSON.parse(appState); if (!appState.movedAway && Date.now() < appState.timestamp + 3600000) { editing.isRestoringState = true; @@ -86,41 +86,41 @@ const AppLoader = ({onLoad}) => { }; }, []); - return ( - loading && ( + return loading ? ( + { + setLoading(false); + }} style={{ - backgroundColor: opacity ? colors.bg : 'rgba(0,0,0,0)', + backgroundColor: colors.bg, width: '100%', height: '100%', - position: 'absolute', - zIndex: 999, + justifyContent: 'center', + alignItems: 'center', borderRadius: 10, + opacity: opacityV, }}> - { - setLoading(false); - }} + - - - - + + - ) + + ) : ( + ); };