Skip to content

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

fix intent recieving on android

ammarahm-ed55caab30a855
diff --git a/apps/mobile/.gitignore b/apps/mobile/.gitignore
index aa4061532..fab1d45bc 100644
--- a/apps/mobile/.gitignore
+++ b/apps/mobile/.gitignore
@@ -65,4 +65,5 @@ react-native-eventsource/
react-native-html-to-pdf/
react-native-receive-sharing-intent/
react-native-scrollable-tab-view/
-react-native-iap/
\ No newline at end of file
+react-native-iap/
+react-native-exit-app/
\ No newline at end of file
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index fdf3210bd..8fbd2cca6 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -1,26 +1,39 @@
import * as NetInfo from '@react-native-community/netinfo';
import {EV} from 'notes-core/common';
import React, {useEffect, useState} from 'react';
-import {Appearance, AppState, Platform, StatusBar} from 'react-native';
+import {
+ Appearance,
+ AppState,
+ Linking,
+ NativeModules,
+ Platform,
+ StatusBar,
+} from 'react-native';
import {enabled} from 'react-native-privacy-snapshot';
import {SafeAreaProvider} from 'react-native-safe-area-context';
import {useTracked} from './src/provider';
import {Actions} from './src/provider/Actions';
import {
+ eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
ToastEvent,
} from './src/services/EventManager';
import {setLoginMessage} from './src/services/Message';
import {editing} from './src/utils';
-import {COLOR_SCHEME} from './src/utils/Colors';
+import {ACCENT, COLOR_SCHEME} from './src/utils/Colors';
import {db} from './src/utils/DB';
-import {eDispatchAction, eStartSyncer} from './src/utils/Events';
+import {eDispatchAction, eOnLoadNote, eStartSyncer} from './src/utils/Events';
import {MMKV} from './src/utils/mmkv';
import {sleep} from './src/utils/TimeUtils';
import {getNote} from './src/views/Editor/Functions';
+import IntentService from './src/services/IntentService';
+import {tabBarRef} from './src/utils/Refs';
+import Navigation from './src/services/Navigation';
+import SplashScreen from 'react-native-splash-screen';
+const {ReceiveSharingIntent} = NativeModules;
-let AppRootView = require('./initializer.intent').IntentView;
+let AppRootView = require('./initializer.root').RootView;
let SettingsService = null;
let Sentry = null;
let appInit = false;
@@ -42,6 +55,26 @@ const onAppStateChanged = async (state) => {
console.log('clearing state', await MMKV.getItem('appState'));
if (appInit) {
await MMKV.removeItem('appState');
+ try {
+ console.log('I am running too from here');
+ _data = await ReceiveSharingIntent.getFileNames();
+ if (_data) {
+ IntentService.setIntent(_data);
+ IntentService.check((event) => {
+ console.log(event);
+ if (event) {
+ eSendEvent(eOnLoadNote, event);
+ tabBarRef.current?.goToPage(1);
+ Navigation.closeDrawer();
+ } else {
+ eSendEvent('nointent');
+ SplashScreen.hide();
+ }
+ });
+ }
+ } catch (e) {
+ console.log(e);
+ }
}
} else {
if (editing.currentlyEditing && appInit) {
@@ -75,7 +108,7 @@ const onNetworkStateChanged = (netInfo) => {
const App = () => {
const [, dispatch] = useTracked(),
- [init, setInit] = useState(false),
+ [init, setInit] = useState(true),
[intent, setIntent] = useState(false);
const syncChanges = async () => {
@@ -96,6 +129,23 @@ const App = () => {
await SettingsService.setTheme();
};
+ const _handleIntent = async (res) => {
+ let url = res ? res.url : '';
+ try {
+ if (res && res.startsWith('ShareMedia://dataUrl')) {
+ _data = await ReceiveSharingIntent.getFileNames(url);
+ }
+ if (_data) {
+ IntentService.setIntent(_data);
+ IntentService.check((event) => {
+ eSendEvent(eOnLoadNote, event);
+ tabBarRef.current?.goToPage(1);
+ Navigation.closeDrawer();
+ });
+ }
+ } catch (e) {}
+ };
+
useEffect(() => {
eSubscribeEvent(eStartSyncer, startSyncer);
eSubscribeEvent(eDispatchAction, (type) => {
@@ -105,6 +155,9 @@ const App = () => {
eSubscribeEvent('nointent', loadMainApp);
Appearance.addChangeListener(onSystemThemeChanged);
let unsub = NetInfo.addEventListener(onNetworkStateChanged);
+ if (Platform.OS === 'ios') {
+ Linking.addEventListener('url', _handleIntent);
+ }
return () => {
EV.unsubscribe('db:refresh', syncChanges);
eUnSubscribeEvent(eStartSyncer, startSyncer);
@@ -114,21 +167,31 @@ const App = () => {
eUnSubscribeEvent('nointent', loadMainApp);
AppState.removeEventListener('change', onAppStateChanged);
Appearance.removeChangeListener(onSystemThemeChanged);
+ if (Platform.OS === 'ios') {
+ Linking.removeEventListener('url', _handleIntent);
+ }
unsub();
};
}, []);
const loadMainApp = () => {
- setIntent(false);
+ dispatch({type: Actions.ALL});
AppRootView = require('./initializer.root').RootView;
- setInit(true);
+ getUser().then(console.log).catch(console.log);
backupData().then((r) => r);
sleep(300).then(() => (appInit = true));
+ db.notes.init().then(() => {
+ dispatch({type: Actions.NOTES});
+ console.log('setting loading to false')
+ dispatch({type: Actions.LOADING, loading: false});
+ });
+
+
//Sentry = require('@sentry/react-native');
- // Sentry.init({
- // dsn:
- // 'https://[email protected]/5519681',
- // });
+ // Sentry.init({
+ // dsn:
+ // 'https://[email protected]/5519681',
+ // });
};
const getUser = async () => {
@@ -156,9 +219,20 @@ const App = () => {
}, []);
const runAfterInit = () => {
- setIntent(true);
- dispatch({type: Actions.ALL});
- getUser().catch((e) => e);
+ IntentService.getIntent()
+ .then(() => {
+ AppRootView = require('./initializer.intent').IntentView;
+ console.log('found intent');
+ setInit(false);
+ dispatch({type: Actions.ALL});
+ setIntent(true);
+ ReceiveSharingIntent.clearFileNames();
+ })
+ .catch((e) => {
+ console.log(e, 'no intent recieved');
+ ReceiveSharingIntent.clearFileNames();
+ loadMainApp();
+ });
};
async function backupData() {
diff --git a/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/IntentActivity.java b/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/IntentActivity.java
index 1d8cebaf1..4a6f29be6 100644
--- a/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/IntentActivity.java
+++ b/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/IntentActivity.java
@@ -13,15 +13,9 @@ public class IntentActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
Intent intent = this.getIntent();
-
intent.setClass(getBaseContext(), MainActivity.class);
+ finishAffinity();
startActivity(intent);
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- finishAndRemoveTask();
- } else {
- finish();
- }
}
}
diff --git a/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/OnClearFromRecentService.java b/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/OnClearFromRecentService.java
index f51ad3584..eb6e568c3 100644
--- a/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/OnClearFromRecentService.java
+++ b/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/OnClearFromRecentService.java
@@ -30,5 +30,6 @@ public class OnClearFromRecentService extends Service {
MMKV mmkv = MMKV.mmkvWithID("default",MMKV.SINGLE_PROCESS_MODE);
mmkv.removeValueForKey("appState");
stopSelf();
+ System.exit(0);
}
}
\ No newline at end of file
diff --git a/apps/mobile/initializer.intent.js b/apps/mobile/initializer.intent.js
index cc8bc5873..9de44a320 100644
--- a/apps/mobile/initializer.intent.js
+++ b/apps/mobile/initializer.intent.js
@@ -1,9 +1,9 @@
import React from 'react';
-import { DialogManager } from './src/components/DialogManager';
-import { DummyText } from './src/components/DummyText';
-import { Toast } from './src/components/Toast';
-import { useTracked } from './src/provider';
-import { EditorWrapper } from './src/views/Editor/EditorWrapper';
+import {DialogManager} from './src/components/DialogManager';
+import {DummyText} from './src/components/DummyText';
+import {Toast} from './src/components/Toast';
+import {useTracked} from './src/provider';
+import {EditorWrapper} from './src/views/Editor/EditorWrapper';
export const IntentView = () => {
const [state] = useTracked();
@@ -11,7 +11,12 @@ export const IntentView = () => {
return (
<>
- <EditorWrapper dimensions={{width: '100%', height: '100%'}} />
+ <EditorWrapper
+ dimensions={{
+ width: '100%',
+ height: '100%',
+ }}
+ />
<Toast />
<DummyText />
<DialogManager colors={colors} />
diff --git a/apps/mobile/initializer.root.js b/apps/mobile/initializer.root.js
index 24e15731a..112f61207 100644
--- a/apps/mobile/initializer.root.js
+++ b/apps/mobile/initializer.root.js
@@ -138,6 +138,7 @@ const AppStack = React.memo(
} else {
setDeviceMode('mobile', size);
}
+ SplashScreen.hide();
}
function setDeviceMode(current, size) {
@@ -156,7 +157,6 @@ const AppStack = React.memo(
if (!movedAway && current !== 'tablet') {
tabBarRef.current?.goToPage(1);
}
- sleep(50).then(() => SplashScreen.hide());
}
const _responder = (e) => {
diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.js
index 1318708cb..1bec20e27 100644
--- a/apps/mobile/src/components/SimpleList/index.js
+++ b/apps/mobile/src/components/SimpleList/index.js
@@ -1,33 +1,35 @@
-import React, { useCallback, useEffect, useState } from 'react';
+import React, {useCallback, useEffect, useState} from 'react';
import {
+ ActivityIndicator,
Platform,
RefreshControl,
StyleSheet,
-
useWindowDimensions,
- View
+ View,
} from 'react-native';
-import { DataProvider, LayoutProvider, RecyclerListView } from 'recyclerlistview';
-import { useTracked } from '../../provider';
-import { Actions } from '../../provider/Actions';
-import { DDS } from '../../services/DeviceDetection';
-import { eSendEvent, ToastEvent } from '../../services/EventManager';
-import { db } from '../../utils/DB';
+import {initialWindowMetrics} from 'react-native-safe-area-context';
+import {DataProvider, LayoutProvider, RecyclerListView} from 'recyclerlistview';
+import {useTracked} from '../../provider';
+import {Actions} from '../../provider/Actions';
+import {DDS} from '../../services/DeviceDetection';
+import {eSendEvent, ToastEvent} from '../../services/EventManager';
+import {dHeight} from '../../utils';
+import {db} from '../../utils/DB';
import {
eOpenJumpToDialog,
eOpenLoginDialog,
- eScrollEvent
+ eScrollEvent,
} from '../../utils/Events';
-import { SIZE } from '../../utils/SizeUtils';
-import { Button } from '../Button';
-import { HeaderMenu } from '../Header/HeaderMenu';
+import {SIZE} from '../../utils/SizeUtils';
+import {Button} from '../Button';
+import {HeaderMenu} from '../Header/HeaderMenu';
import Seperator from '../Seperator';
import TagItem from '../TagItem';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
-import { ListHeaderComponent } from './ListHeaderComponent';
-import { NotebookItemWrapper } from './NotebookItemWrapper';
-import { NoteItemWrapper } from './NoteItemWrapper';
+import {ListHeaderComponent} from './ListHeaderComponent';
+import {NotebookItemWrapper} from './NotebookItemWrapper';
+import {NoteItemWrapper} from './NoteItemWrapper';
const header = {
type: 'MAIN_HEADER',
@@ -36,8 +38,6 @@ const header = {
const SimpleList = ({
data,
type,
- placeholder,
- RenderItem,
customRefresh,
customRefreshing,
refreshCallback,
@@ -45,15 +45,16 @@ const SimpleList = ({
scrollRef,
jumpToDialog,
placeholderData,
+ loading,
}) => {
const [state, dispatch] = useTracked();
- const {colors, selectionMode} = state;
+ const {colors} = state;
const searchResults = {...state.searchResults};
const [refreshing, setRefreshing] = useState(false);
const [dataProvider, setDataProvider] = useState(
new DataProvider((r1, r2) => {
return r1 !== r2;
- }),
+ }).cloneWithRows([header, {type: 'empty'}]),
);
const {width, fontScale} = useWindowDimensions();
@@ -70,7 +71,13 @@ const SimpleList = ({
}, [listData, searchResults.results]);
const loadData = () => {
- let mainData = [header, ...listData];
+ let mainData = [header, {type: 'empty'}];
+ console.log(mainData);
+ mainData =
+ !listData || listData.length === 0
+ ? mainData
+ : [header, ...listData];
+ console.log(mainData,'main data');
setDataProvider(dataProvider.cloneWithRows(mainData));
};
@@ -149,11 +156,10 @@ const SimpleList = ({
style={[
{
backgroundColor: colors.bg,
- height: '100%',
+ height: dHeight - 250 - initialWindowMetrics.insets.top,
+ width: '100%',
},
]}>
- <ListHeaderComponent type={type} />
-
<View
style={{
flexGrow: 1,
@@ -161,9 +167,11 @@ const SimpleList = ({
alignItems: 'center',
}}>
<Heading>{placeholderData.heading}</Heading>
- <Paragraph color={colors.icon}>{placeholderData.paragraph}</Paragraph>
+ <Paragraph color={colors.icon}>
+ {loading ? placeholderData.loading : placeholderData.paragraph}
+ </Paragraph>
<Seperator />
- {placeholderData.button && (
+ {placeholderData.button && !loading ? (
<Button
onPress={placeholderData.action}
title={placeholderData.button}
@@ -171,6 +179,8 @@ const SimpleList = ({
type="transparent"
fontSize={SIZE.md}
/>
+ ) : (
+ <ActivityIndicator color={colors.accent} />
)}
</View>
</View>
@@ -194,6 +204,10 @@ const SimpleList = ({
dim.width = width;
dim.height = 110 * fontScale;
break;
+ case 'empty':
+ dim.width = width;
+ dim.height = 600;
+ break;
case 'topic':
dim.width = width;
dim.height = 80 * fontScale;
@@ -251,12 +265,12 @@ const SimpleList = ({
);
case 'header':
return <RenderSectionHeader item={data} index={index} />;
+ case 'empty':
+ return _ListEmptyComponent;
}
};
- return !listData || listData.length === 0 || !dataProvider ? (
- _ListEmptyComponent
- ) : (
+ return (
<RecyclerListView
ref={scrollRef}
layoutProvider={_layoutProvider}
@@ -297,36 +311,3 @@ const SimpleList = ({
};
export default SimpleList;
-
-const styles = StyleSheet.create({
- loginCard: {
- width: '100%',
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'flex-start',
- paddingHorizontal: 12,
- alignSelf: 'center',
- height: 40,
- borderRadius: 0,
- position: 'relative',
- },
- loginIcon: {
- textAlign: 'center',
- textAlignVertical: 'center',
- },
- searchHeader: {
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'space-between',
- paddingHorizontal: 12,
- height: 40,
- },
- emptyList: {
- height: '100%',
- width: '100%',
- alignItems: 'center',
- alignSelf: 'center',
- justifyContent: 'center',
- opacity: 1,
- },
-});
diff --git a/apps/mobile/src/navigation/Drawer.js b/apps/mobile/src/navigation/Drawer.js
index 4e6cefeda..3d284621a 100644
--- a/apps/mobile/src/navigation/Drawer.js
+++ b/apps/mobile/src/navigation/Drawer.js
@@ -6,6 +6,7 @@ import {useTracked} from '../provider';
import {eSubscribeEvent, eUnSubscribeEvent} from '../services/EventManager';
import {eCloseSideMenu, eOpenSideMenu} from '../utils/Events';
import {sideMenuRef} from '../utils/Refs';
+import { sleep } from '../utils/TimeUtils';
import {NavigatorStack} from './NavigatorStack';
const Drawer = createDrawerNavigator();
@@ -14,6 +15,15 @@ export const NavigationStack = ({component = NavigatorStack}) => {
const [state] = useTracked();
const {deviceMode} = state;
const [locked, setLocked] = React.useState(false);
+ const [initRender, setInitRender] = React.useState(true);
+
+ React.useEffect(() => {
+ console.log("rendering drawer");
+ sleep(1000).then(() => {
+ setInitRender(false);
+ })
+
+ }, []);
const setGestureDisabled = () => {
setLocked(true);
@@ -40,8 +50,9 @@ export const NavigationStack = ({component = NavigatorStack}) => {
gestureEnabled: locked || deviceMode !== 'mobile' ? false : true,
}}
drawerStyle={{
- width: deviceMode !== 'mobile' ? 0 : '65%',
- borderRightWidth:0,
+ width: initRender ? 0 : deviceMode !== 'mobile' ? 0 : '65%',
+ height:initRender? 0 : null,
+ borderRightWidth: 0,
}}
edgeWidth={200}
drawerType="slide"
diff --git a/apps/mobile/src/provider/Reducer.js b/apps/mobile/src/provider/Reducer.js
index fbe18bfaf..dba47fd83 100644
--- a/apps/mobile/src/provider/Reducer.js
+++ b/apps/mobile/src/provider/Reducer.js
@@ -28,7 +28,7 @@ export const reducer = (state, action) => {
case Actions.LOADING: {
return {
...state,
- syncing: action.loading,
+ loading: action.loading,
};
}
case Actions.CLEAR_ALL: {
diff --git a/apps/mobile/src/services/IntentService.js b/apps/mobile/src/services/IntentService.js
index f23453733..30d4466ae 100644
--- a/apps/mobile/src/services/IntentService.js
+++ b/apps/mobile/src/services/IntentService.js
@@ -1,49 +1,72 @@
-import ReceiveSharingIntent from 'react-native-receive-sharing-intent';
-import {setIntent} from '../views/Editor/Functions';
+import {NativeModules, Platform} from 'react-native';
+const {ReceiveSharingIntent} = NativeModules;
+let currentIntent = null;
+const isIos = Platform.OS === 'ios';
-let previousIntent = {
- text: null,
- weblink: null,
-};
-
-async function check(callback) {
- ReceiveSharingIntent.getReceivedFiles(
- (d) => {
- let data = d[0];
- if (data.text || data.weblink) {
- let text = data.text;
- let weblink = data.weblink;
- let delta = null;
-
- if (weblink && text) {
- delta = [{insert: `${text + ' ' + weblink}`}];
- text = data.text + ' ' + data.weblink;
- } else if (text && !weblink) {
- delta = [{insert: `${text}`}];
- text = data.text;
- } else if (weblink) {
- delta = [{insert: `${weblink}`}];
- text = weblink;
+function getIntent() {
+ return new Promise(async (resolve, reject) => {
+ let initialUrlIOS;
+ let _data = null;
+ try {
+ if (isIos) {
+ initialUrlIOS = await Linking.getInitialURL();
+ if (res && res.startsWith('ShareMedia://dataUrl')) {
+ _data = await ReceiveSharingIntent.getFileNames(initialUrlIOS.url);
+ } else {
+ reject('unsupported url');
}
-
- previousIntent.text = text;
- previousIntent.weblink = weblink;
- setIntent();
- callback({
- type: 'intent',
- data: delta,
- });
} else {
- callback(null);
+ _data = await ReceiveSharingIntent.getFileNames();
}
- ReceiveSharingIntent.clearReceivedFiles();
- },
- (error) => {
- callback(null);
- },
- );
+ } catch (e) {
+ reject(e);
+ }
+ if (!_data) {
+ console.log(_data);
+ return;
+ }
+ setIntent(_data, resolve, reject);
+ });
+}
+
+function setIntent(d, resolve, reject) {
+ let data = d[0];
+ if (data.text || data.weblink) {
+ let text = data.text;
+ let weblink = data.weblink;
+ let delta = null;
+
+ if (weblink && text) {
+ delta = [{insert: `${text + ' ' + weblink}`}];
+ text = data.text + ' ' + data.weblink;
+ } else if (text && !weblink) {
+ delta = [{insert: `${text}`}];
+ text = data.text;
+ } else if (weblink) {
+ delta = [{insert: `${weblink}`}];
+ text = weblink;
+ }
+ currentIntent = {
+ type: 'intent',
+ data: delta,
+ };
+ if (resolve) {
+ resolve(true);
+ }
+ } else {
+ if (reject) {
+ reject('nothing found');
+ }
+ }
+}
+
+function check(callback) {
+ callback(currentIntent);
+ currentIntent = null;
}
export default {
+ getIntent,
check,
+ setIntent,
};
diff --git a/apps/mobile/src/views/Editor/EditorWrapper.js b/apps/mobile/src/views/Editor/EditorWrapper.js
index 83248894e..524bfef12 100644
--- a/apps/mobile/src/views/Editor/EditorWrapper.js
+++ b/apps/mobile/src/views/Editor/EditorWrapper.js
@@ -8,8 +8,8 @@ import {useTracked} from '../../provider';
import {eSendEvent} from '../../services/EventManager';
import {eOnLoadNote} from '../../utils/Events';
import Editor from './index';
-import {editorRef} from "../../utils/Refs"
-import { DDS } from '../../services/DeviceDetection';
+import {editorRef} from '../../utils/Refs';
+import {DDS} from '../../services/DeviceDetection';
let prevVal = 0;
let finalValue = 80;
let anim2 = new Animated.Value(0);
@@ -77,7 +77,9 @@ function opacityAnim(a, b, c) {
}).start();
}
-const AnimatedKeyboardView = Animated.createAnimatedComponent(KeyboardAvoidingView)
+const AnimatedKeyboardView = Animated.createAnimatedComponent(
+ KeyboardAvoidingView,
+);
export const EditorWrapper = ({dimensions}) => {
const [state] = useTracked();
@@ -88,7 +90,7 @@ export const EditorWrapper = ({dimensions}) => {
<SafeAreaView
ref={editorRef}
style={{
- width:DDS.isLargeTablet()? dimensions.width * 0.55 : dimensions.width,
+ width: DDS.isLargeTablet() ? dimensions.width * 0.55 : dimensions.width,
height: '100%',
backgroundColor: colors.bg,
}}>
@@ -107,7 +109,7 @@ export const EditorWrapper = ({dimensions}) => {
onHandlerStateChange={onHandlerStateChange}
onGestureEvent={onGestureEvent}>
<AnimatedKeyboardView
- behavior={Platform.OS === 'ios' ? 'padding' : null}
+ behavior={Platform.OS === 'ios' ? 'padding' : null}
style={{
transform: [
{
@@ -160,7 +162,7 @@ export const EditorWrapper = ({dimensions}) => {
</Animated.Text>
</View>
- <Editor/>
+ <Editor />
</AnimatedKeyboardView>
</PanGestureHandler>
</SafeAreaView>
diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.js
index b3ca4d1d9..6170b15f6 100644
--- a/apps/mobile/src/views/Editor/Functions.js
+++ b/apps/mobile/src/views/Editor/Functions.js
@@ -1,21 +1,20 @@
-import {createRef} from 'react';
-import {Linking, Platform} from 'react-native';
-import {updateEvent} from '../../components/DialogManager/recievers';
-import {Actions} from '../../provider/Actions';
-import {eSendEvent, sendNoteEditedEvent} from '../../services/EventManager';
-import {eOnLoadNote, refreshNotesPage} from '../../utils/Events';
-import {editing} from '../../utils';
-import {sleep, timeConverter} from '../../utils/TimeUtils';
-import {normalize} from '../../utils/SizeUtils';
-import {db} from '../../utils/DB';
-import {COLORS_NOTE, COLOR_SCHEME} from '../../utils/Colors';
-import {hexToRGBA} from '../../utils/ColorUtils';
-import {DDS} from '../../services/DeviceDetection';
-import {sideMenuRef, tabBarRef} from '../../utils/Refs';
-import {MMKV} from '../../utils/mmkv';
-import IntentService from '../../services/IntentService';
-import Navigation from '../../services/Navigation';
+import { createRef } from 'react';
+import { Linking, Platform } from 'react-native';
import SplashScreen from 'react-native-splash-screen';
+import { updateEvent } from '../../components/DialogManager/recievers';
+import { Actions } from '../../provider/Actions';
+import { DDS } from '../../services/DeviceDetection';
+import { eSendEvent, sendNoteEditedEvent } from '../../services/EventManager';
+import IntentService from '../../services/IntentService';
+import { editing } from '../../utils';
+import { COLORS_NOTE, COLOR_SCHEME } from '../../utils/Colors';
+import { hexToRGBA } from '../../utils/ColorUtils';
+import { db } from '../../utils/DB';
+import { eOnLoadNote, refreshNotesPage } from '../../utils/Events';
+import { MMKV } from '../../utils/mmkv';
+import { sideMenuRef, tabBarRef } from '../../utils/Refs';
+import { normalize } from '../../utils/SizeUtils';
+import { sleep, timeConverter } from '../../utils/TimeUtils';
export const EditorWebView = createRef();
@@ -387,6 +386,7 @@ export async function onWebViewLoad(premium, colors, event) {
webviewInit = true;
}
async function loadEditorState() {
+ console.log('here stuck')
if (sideMenuRef.current !== null) {
if (intent) {
console.log('clearing here');
@@ -405,18 +405,16 @@ async function loadEditorState() {
}
}
} else {
+ // Checks intent only when app is loading
+ console.log('here checking for intent and waiting')
IntentService.check((event) => {
if (event) {
+ console.log('I am handling the intent')
intent = true;
eSendEvent(eOnLoadNote, event);
- Navigation.closeDrawer();
- tabBarRef.current?.goToPage(1);
SplashScreen.hide();
} else {
- console.log('loading main app',intent);
- if (intent) return;
eSendEvent('nointent');
- console.log('sent no intent');
}
});
}
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index 222d0fae4..b89874531 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -1,5 +1,4 @@
import React, {useCallback, useEffect} from 'react';
-import * as Keychain from 'react-native-keychain';
import {ContainerBottomButton} from '../../components/Container/ContainerBottomButton';
import SimpleList from '../../components/SimpleList';
import {useTracked} from '../../provider';
@@ -10,12 +9,10 @@ import SearchService from '../../services/SearchService';
import {scrollRef} from '../../utils';
import {eOnLoadNote, eScrollEvent} from '../../utils/Events';
import {tabBarRef} from '../../utils/Refs';
-import Storage from '../../utils/storage';
-import * as Sentry from '@sentry/react-native';
export const Home = ({navigation}) => {
const [state, dispatch] = useTracked();
- const {notes} = state;
+ const {notes, loading} = state;
const onFocus = useCallback(() => {
eSendEvent(eScrollEvent, {name: 'Notes', type: 'in'});
@@ -32,7 +29,7 @@ export const Home = ({navigation}) => {
dispatch({
type: Actions.CONTAINER_BOTTOM_BUTTON,
state: {
- onPress:_onPressBottomButton
+ onPress: _onPressBottomButton,
},
});
@@ -56,7 +53,7 @@ export const Home = ({navigation}) => {
navigation.removeListener('focus', onFocus);
navigation.removeListener('blur', onBlur);
};
- },[]);
+ }, []);
useEffect(() => {
if (navigation.isFocused()) {
@@ -73,7 +70,6 @@ export const Home = ({navigation}) => {
};
const _onPressBottomButton = (event) => {
-
if (!DDS.isLargeTablet()) {
tabBarRef.current?.goToPage(1);
} else {
@@ -89,6 +85,7 @@ export const Home = ({navigation}) => {
type="notes"
isHome={true}
pinned={true}
+ loading={loading}
sortMenuButton={true}
placeholderText={`Notes you write appear here`}
jumpToDialog={true}
@@ -97,6 +94,7 @@ export const Home = ({navigation}) => {
paragraph: 'You have not added any notes yet.',
button: 'Add your First Note',
action: _onPressBottomButton,
+ loading: 'We are loading your notes.',
}}
/>