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
fix crash on app launch
Ammar Ahmedc0ba6c8f3d41
diff --git a/apps/mobile/patches/react-native-fingerprint-scanner+5.0.0.patch b/apps/mobile/patches/react-native-fingerprint-scanner+5.0.0.patchnew file mode 100644index 000000000..fe3f9a4f8--- /dev/null+++ b/apps/mobile/patches/react-native-fingerprint-scanner+5.0.0.patch@@ -0,0 +1,17 @@+diff --git a/node_modules/react-native-fingerprint-scanner/react-native.config.js b/node_modules/react-native-fingerprint-scanner/react-native.config.js+deleted file mode 100644+index 5f794ab..0000000+--- a/node_modules/react-native-fingerprint-scanner/react-native.config.js++++ /dev/null+@@ -1,11 +0,0 @@+-module.exports = {+- dependency: {+- platforms: {+- ios: {},+- android: {},+- },+- assets: [],+- // hooks are considered anti-pattern, please avoid them+- hooks: {},+- },+-};diff --git a/apps/mobile/src/components/launcher/index.js b/apps/mobile/src/components/launcher/index.jsindex 958240890..fa0d79bd9 100644--- a/apps/mobile/src/components/launcher/index.js+++ b/apps/mobile/src/components/launcher/index.js@@ -1,5 +1,6 @@+import { EVENTS } from 'notes-core/common';import React, { useEffect, useRef } from 'react';-import { Platform, View } from 'react-native';+import { NativeModules, Platform, View } from 'react-native';import RNBootSplash from 'react-native-bootsplash';import { checkVersion } from 'react-native-check-version';import { editorState } from '../../screens/editor/tiptap/utils';@@ -18,7 +19,7 @@ import { useThemeStore } from '../../stores/use-theme-store';import { useUserStore } from '../../stores/use-user-store';import { db, loadDatabase } from '../../utils/database';import { MMKV } from '../../utils/database/mmkv';-import { eOpenAnnouncementDialog } from '../../utils/events';+import { eCloseProgressDialog, eOpenAnnouncementDialog } from '../../utils/events';import { tabBarRef } from '../../utils/global-refs';import { SIZE } from '../../utils/size';import { sleep } from '../../utils/time';@@ -60,15 +61,30 @@ const Launcher = React.memo(setImmediate(() => {setLoading(false);setImmediate(() => doAppLoadActions());+ db?.eventManager?.unsubscribe(EVENTS.databaseMigrating, onDatabaseMigratingProgess);});});});};+ const onDatabaseMigratingProgess = React.useCallback(data => {+ presentSheet({+ progress: true,+ title: 'Migrating database',+ paragraph: 'Please wait while we migrate your data. Do not close the app.'+ });+ });++ const onMigrationCompleted = React.useCallback(data => {+ eSendEvent(eCloseProgressDialog);+ });+const init = async () => {if (!dbInitCompleted.current) {- if (!verifyUser) await RNBootSplash.hide({ fade: true });+ await RNBootSplash.hide({ fade: true });await loadDatabase();+ db?.eventManager?.subscribe(EVENTS.databaseMigrating, onDatabaseMigratingProgess);+ db?.eventManager?.subscribe(EVENTS.databaseMigrated, onMigrationCompleted);await db.init();dbInitCompleted.current = true;}@@ -202,6 +218,10 @@ const Launcher = React.memo(onUnlockBiometrics();}init();++ return () => {+ db?.eventManager?.unsubscribe(EVENTS.databaseMigrated, onMigrationCompleted);+ };}, [verifyUser]);const onSubmit = async () => {diff --git a/apps/mobile/src/navigation/index.js b/apps/mobile/src/navigation/index.jsindex c714e3fbf..a77ee0619 100644--- a/apps/mobile/src/navigation/index.js+++ b/apps/mobile/src/navigation/index.js@@ -12,17 +12,19 @@ export const ApplicationHolder = React.memo(() => {const loading = useNoteStore(state => state.loading);const introCompleted = useSettingStore(state => state.settings.introCompleted);- return loading && introCompleted ? (+ return (<>- <SafeAreaView>- <Header />- <DelayLayout animated={false} wait={loading} />- </SafeAreaView>- </>- ) : (- <>- <TabsHolder />- <Toast />+ {loading && introCompleted ? (+ <>+ <Header />+ <DelayLayout animated={false} wait={loading} />+ </>+ ) : (+ <>+ <TabsHolder />+ <Toast />+ </>+ )}<DialogProvider /></>);diff --git a/apps/mobile/src/services/biometrics.ts b/apps/mobile/src/services/biometrics.tsindex b4512172d..392c199bd 100644--- a/apps/mobile/src/services/biometrics.ts+++ b/apps/mobile/src/services/biometrics.ts@@ -15,6 +15,7 @@ const KeychainConfig = Platform.select({async function isBiometryAvailable() {try {+ console.log('scanner status', FingerprintScanner);return await FingerprintScanner.isSensorAvailable();} catch (e) {console.log(e, 'sensor not available');diff --git a/apps/mobile/src/utils/hooks/useAppEvents.js b/apps/mobile/src/utils/hooks/useAppEvents.jsindex d6891ad41..611d73251 100644--- a/apps/mobile/src/utils/hooks/useAppEvents.js+++ b/apps/mobile/src/utils/hooks/useAppEvents.js@@ -80,15 +80,13 @@ export const useAppEvents = () => {useEffect(() => {if (!loading) {const eventManager = db?.eventManager;- eventManager?.subscribe(EVENTS.syncProgress, onSyncProgress);- let sub = eventManager?.subscribe(EVENTS.databaseSyncRequested, onRequestPartialSync);eventManager?.subscribe(EVENTS.syncCompleted, onSyncComplete);- console.log('SUBSCRIBED', sub);+ db?.eventManager?.subscribe(EVENTS.syncProgress, onSyncProgress);+ db?.eventManager?.subscribe(EVENTS.databaseSyncRequested, onRequestPartialSync);}return () => {const eventManager = db?.eventManager;- console.log('UNSUBSCRIBED');eventManager?.unsubscribe(EVENTS.syncCompleted, onSyncComplete);eventManager?.unsubscribe(EVENTS.syncProgress, onSyncProgress);eventManager?.unsubscribe(EVENTS.databaseSyncRequested, onRequestPartialSync);@@ -101,6 +99,7 @@ export const useAppEvents = () => {Linking.addEventListener('url', onUrlRecieved),SodiumEventEmitter.addListener('onSodiumProgress', onFileEncryptionProgress)];+EV.subscribe(EVENTS.appRefreshRequested, onSyncComplete);EV.subscribe(EVENTS.userLoggedOut, onLogout);EV.subscribe(EVENTS.userEmailConfirmed, onEmailVerified);diff --git a/apps/mobile/webpack.config.cjs b/apps/mobile/webpack.config.cjsindex 88bedfa98..559dad15c 100644--- a/apps/mobile/webpack.config.cjs+++ b/apps/mobile/webpack.config.cjs@@ -155,7 +155,8 @@ module.exports = env => {/node_modules(.*[/\\])+selderee/,/node_modules(.*[/\\])+html-to-text/,/node_modules(.*[/\\])+buffer/,- /node_modules(.*[/\\])+readable-stream/+ /node_modules(.*[/\\])+readable-stream/,+ /node_modules(.*[/\\])+react-native-fingerprint-scanner/],use: {loader: 'babel-loader',