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
improve error handling
ammarahm-edeb952dec67b5
diff --git a/apps/mobile/App.js b/apps/mobile/App.jsindex def180f7b..32017a2fa 100644--- a/apps/mobile/App.js+++ b/apps/mobile/App.js@@ -1,11 +1,10 @@-import Clipboard from '@react-native-clipboard/clipboard';import React, { useEffect } from 'react';-import { ScrollView, Text, View } from 'react-native';+import RNBootSplash from 'react-native-bootsplash';import { GestureHandlerRootView } from 'react-native-gesture-handler';-import { SafeAreaProvider } from 'react-native-safe-area-context';+import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';+import { Dialog } from './src/components/dialog';import Launcher from './src/components/launcher';-import { Button } from './src/components/ui/button';-import Paragraph from './src/components/ui/typography/paragraph';+import { Issue } from './src/components/sheets/github/issue';import { ApplicationHolder } from './src/navigation';import Notifications from './src/services/notifications';import SettingsService from './src/services/settings';@@ -13,7 +12,13 @@ import { TipManager } from './src/services/tip-manager';import { useUserStore } from './src/stores/use-user-store';import { useAppEvents } from './src/utils/hooks/use-app-events';-class MyErrorBoundary extends React.Component {+const error =+ stack => `Please let us know what happened. What steps we can take to reproduce the issue here.++_______________________________+Stacktrace: ${stack}`;++class ExceptionHandler extends React.Component {state = {hasError: false,error: null@@ -25,47 +30,28 @@ class MyErrorBoundary extends React.Component {componentDidCatch(error, errorInfo) {// A custom error logging function}++ componentDidMount() {+ RNBootSplash.hide();+ }+render() {return this.state.hasError ? (- <View- style={{- flex: 1,- justifyContent: 'center',- alignItems: 'center',- paddingHorizontal: 12,- paddingVertical: 50- }}- >- <ScrollView+ <SafeAreaProvider>+ <SafeAreaViewstyle={{- borderWidth: 1,- borderRadius: 10,- padding: 12,- borderColor: 'red'+ flex: 1,+ paddingTop: 10}}>- <Paragraph- style={{- color: 'red'- }}- selectable={true}- >- {this.state.error.stack}- </Paragraph>- </ScrollView>- <Button- title="Copy Error"- type="error"- style={{- marginTop: 20,- width: '100%'- }}- onPress={() => {- Clipboard.setString(this.state.error.stack);- alert('Error copied');- }}- />- </View>+ <Issue+ defaultBody={error(this.state.error?.stack)}+ defaultTitle={this.state.error?.title || 'Unknown Error'}+ issueTitle="An exception occured"+ />+ <Dialog />+ </SafeAreaView>+ </SafeAreaProvider>) : (this.props.children);@@ -82,27 +68,31 @@ const App = () => {useUserStore.getState().setVerifyUser(true);}setTimeout(() => {- console.log('run later');SettingsService.onFirstLaunch();Notifications.get();TipManager.init();}, 100);}, []);+ return (+ <GestureHandlerRootView+ style={{+ flex: 1+ }}+ >+ <SafeAreaProvider>+ <ApplicationHolder />+ <Launcher />+ </SafeAreaProvider>+ </GestureHandlerRootView>+ );+};+const AppWithErrorBoundry = () => {return (- <MyErrorBoundary>- <GestureHandlerRootView- style={{- flex: 1- }}- >- <SafeAreaProvider>- <ApplicationHolder />- <Launcher />- </SafeAreaProvider>- </GestureHandlerRootView>- </MyErrorBoundary>+ <ExceptionHandler>+ <App />+ </ExceptionHandler>);};-export default App;+export default AppWithErrorBoundry;diff --git a/apps/mobile/src/components/sheets/github/issue.js b/apps/mobile/src/components/sheets/github/issue.jsindex 18ac71255..2df1e8595 100644--- a/apps/mobile/src/components/sheets/github/issue.js+++ b/apps/mobile/src/components/sheets/github/issue.js@@ -1,29 +1,29 @@import Clipboard from '@react-native-clipboard/clipboard';import React, { useRef, useState } from 'react';import { Linking, Platform, Text, TextInput, View } from 'react-native';-import { useThemeStore } from '../../../stores/use-theme-store';-import { useUserStore } from '../../../stores/use-user-store';+import { APP_VERSION } from '../../../../version';import { eSendEvent, ToastEvent } from '../../../services/event-manager';import PremiumService from '../../../services/premium';-import { APP_VERSION } from '../../../../version';+import { useThemeStore } from '../../../stores/use-theme-store';+import { useUserStore } from '../../../stores/use-user-store';import { db } from '../../../utils/database';import { eCloseProgressDialog } from '../../../utils/events';import { openLinkInBrowser } from '../../../utils/functions';import { SIZE } from '../../../utils/size';import { sleep } from '../../../utils/time';-import { Button } from '../../ui/button';import DialogHeader from '../../dialog/dialog-header';import { presentDialog } from '../../dialog/functions';+import { Button } from '../../ui/button';import Seperator from '../../ui/seperator';import Paragraph from '../../ui/typography/paragraph';-import deviceInfoModule from 'react-native-device-info';-export const Issue = () => {+export const Issue = ({ defaultTitle, defaultBody, issueTitle }) => {const colors = useThemeStore(state => state.colors);- const body = useRef(null);- const title = useRef(null);+ const body = useRef(defaultBody);+ const title = useRef(defaultTitle);const user = useUserStore(state => state.user);const [loading, setLoading] = useState(false);+ const bodyRef = useRef();const onPress = async () => {if (loading) return;@@ -95,12 +95,17 @@ Logged in: ${user ? 'yes' : 'no'}`,return (<Viewstyle={{- paddingHorizontal: 12+ paddingHorizontal: 12,+ width: '100%'}}><DialogHeader- title="Report issue"- paragraph="Let us know if you have faced any issue/bug while using Notesnook."+ title={issueTitle || 'Report issue'}+ paragraph={+ issueTitle+ ? 'We are sorry, it seems that the app crashed due to an error. You can submit a bug report below so we can fix this asap.'+ : 'Let us know if you have faced any issue/bug while using Notesnook.'+ }/><Seperator half />@@ -108,6 +113,7 @@ Logged in: ${user ? 'yes' : 'no'}`,<TextInputplaceholder="Title"onChangeText={v => (title.current = v)}+ defaultValue={title.current}style={{borderWidth: 1,borderColor: colors.nav,@@ -122,6 +128,7 @@ Logged in: ${user ? 'yes' : 'no'}`,/><TextInput+ ref={bodyRef}placeholder={`Tell us more about the issue you are facing.For example:@@ -131,6 +138,17 @@ For example:numberOfLines={5}textAlignVertical="top"onChangeText={v => (body.current = v)}+ onLayout={() => {+ if (body.current) {+ bodyRef.current?.setNativeProps({+ text: body.current,+ selection: {+ start: 0,+ end: 0+ }+ });+ }+ }}style={{borderWidth: 1,borderColor: colors.nav,