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 performance bottleneck
ammarahm-ed05ff7a832b2c
diff --git a/apps/mobile/App.js b/apps/mobile/App.jsindex 05afe5fb0..9f7339e45 100644--- a/apps/mobile/App.js+++ b/apps/mobile/App.js@@ -43,21 +43,24 @@ const App = () => {const startSyncer = async () => {let user = await db.user.get();if (user) {- db.ev.subscribe('sync', async () => {- dispatch({type: ACTIONS.SYNCING, syncing: true});- await db.sync();- let u = await db.user.get();- dispatch({type: ACTIONS.USER, user: u});- dispatch({type: ACTIONS.ALL});- dispatch({type: ACTIONS.SYNCING, syncing: false});- });+ db.ev.subscribe('sync', _syncFunc);}};+ const _syncFunc = async () => {+ dispatch({type: ACTIONS.SYNCING, syncing: true});+ await db.sync();+ let u = await db.user.get();+ dispatch({type: ACTIONS.USER, user: u});+ dispatch({type: ACTIONS.ALL});+ dispatch({type: ACTIONS.SYNCING, syncing: false});+ }+useEffect(() => {eSubscribeEvent(eStartSyncer, startSyncer);return () => {+ db.ev.unsubscribe('sync', _syncFunc);eUnSubscribeEvent(eStartSyncer, startSyncer);};},[]);diff --git a/apps/mobile/src/components/Container/index.js b/apps/mobile/src/components/Container/index.jsindex c192448f0..acdcb3121 100644--- a/apps/mobile/src/components/Container/index.js+++ b/apps/mobile/src/components/Container/index.js@@ -120,19 +120,25 @@ export const Container = ({};const clearSearch = () => {- searchResult = null;- setText(null);- inputRef.current?.setNativeProps({- text: '',- });- dispatch({- type: ACTIONS.SEARCH_RESULTS,- results: {- results: [],- type: null,- keyword: null,- },- });+ if (searchResults.results && searchResults.results.length > 0) {+ searchResult = null;+ if (text) {+ setText(null);+ }+ inputRef.current?.setNativeProps({+ text: '',+ });+ dispatch({+ type: ACTIONS.SEARCH_RESULTS,+ results: {+ results: [],+ type: null,+ keyword: null,+ },+ });+ }++};useEffect(() => {@@ -167,6 +173,7 @@ export const Container = ({}, []);useEffect(() => {+selection.data = data;selection.type = type;eSubscribeEvent(eScrollEvent, onScroll);diff --git a/apps/mobile/src/components/Menu/index.js b/apps/mobile/src/components/Menu/index.jsindex 5d997ea30..9453dfcf9 100644--- a/apps/mobile/src/components/Menu/index.js+++ b/apps/mobile/src/components/Menu/index.js@@ -47,9 +47,12 @@ export const Menu = ({noTextMode = false,onButtonLongPress = () => {},}) => {- const [state, dispatch] = useTracked();- const {colors, tags, colorNotes, user, currentScreen, syncing} = state;-+ let currentScreen = '';+ let colors = COLOR_SCHEME_LIGHT;+ let tags = [];+ let colorNotes = [];+ let user = null+ let syncing = false// todofunction changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {@@ -60,7 +63,7 @@ export const Menu = ({}useEffect(() => {- dispatch({type: ACTIONS.TAGS});+ //dispatch({type: ACTIONS.TAGS});}, []);const listItems = [@@ -70,7 +73,6 @@ export const Menu = ({func: () => NavigationService.navigate('Home'),close: true,},-{name: 'Notebooks',icon: 'book-outline',