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
defer updating state
ammarahm-ed0c95d81b1557
diff --git a/apps/mobile/src/components/SelectionWrapper/backfill.js b/apps/mobile/src/components/SelectionWrapper/backfill.jsindex 80369b65a..9c2bab958 100644--- a/apps/mobile/src/components/SelectionWrapper/backfill.js+++ b/apps/mobile/src/components/SelectionWrapper/backfill.js@@ -12,7 +12,7 @@ export const Filler = ({item, background}) => {const color = 'gray';- return (+ return currentEditingNote === item.id ? (<Viewstyle={{position: 'absolute',@@ -25,5 +25,5 @@ export const Filler = ({item, background}) => {</View>- );+ ) : null};diff --git a/apps/mobile/src/views/Editor/EditorHeader.js b/apps/mobile/src/views/Editor/EditorHeader.jsindex a0cab4a97..47bf008bc 100644--- a/apps/mobile/src/views/Editor/EditorHeader.js+++ b/apps/mobile/src/views/Editor/EditorHeader.js@@ -1,5 +1,5 @@-import { EV, EVENTS } from 'notes-core/common';-import React, { useEffect, useRef } from 'react';+import {EV, EVENTS} from 'notes-core/common';+import React, {useEffect, useRef} from 'react';import {BackHandler,InteractionManager,@@ -8,17 +8,17 @@ import {Vibration,View} from 'react-native';-import { useSafeAreaInsets } from 'react-native-safe-area-context';-import { notesnook } from '../../../e2e/test.ids';-import { ActionIcon } from '../../components/ActionIcon';-import { ActionSheetEvent } from '../../components/DialogManager/recievers';-import { useTracked } from '../../provider';+import {useSafeAreaInsets} from 'react-native-safe-area-context';+import {notesnook} from '../../../e2e/test.ids';+import {ActionIcon} from '../../components/ActionIcon';+import {ActionSheetEvent} from '../../components/DialogManager/recievers';+import {useTracked} from '../../provider';import {useEditorStore,useSettingStore,useUserStore} from '../../provider/stores';-import { DDS } from '../../services/DeviceDetection';+import {DDS} from '../../services/DeviceDetection';import {eSendEvent,eSubscribeEvent,@@ -26,8 +26,8 @@ import {ToastEvent} from '../../services/EventManager';import Navigation from '../../services/Navigation';-import { editing, SUBSCRIPTION_STATUS } from '../../utils';-import { db } from '../../utils/database';+import {editing, SUBSCRIPTION_STATUS} from '../../utils';+import {db} from '../../utils/database';import {eClearEditor,eCloseFullscreenEditor,@@ -37,9 +37,9 @@ import {eOpenPremiumDialog,eOpenPublishNoteDialog} from '../../utils/Events';-import { tabBarRef } from '../../utils/Refs';-import { sleep } from '../../utils/TimeUtils';-import { EditorTitle } from './EditorTitle';+import {tabBarRef} from '../../utils/Refs';+import {sleep} from '../../utils/TimeUtils';+import {EditorTitle} from './EditorTitle';import {clearEditor,clearTimer,@@ -49,12 +49,12 @@ import {setColors,startClosingSession} from './Functions';-import { ProgressCircle } from './ProgressCircle';-import tiny, { safeKeyboardDismiss } from './tiny/tiny';-import { endSearch } from './tiny/toolbar/commands';-import { toolbarRef } from './tiny/toolbar/constants';+import {ProgressCircle} from './ProgressCircle';+import tiny, {safeKeyboardDismiss} from './tiny/tiny';+import {endSearch} from './tiny/toolbar/commands';+import {toolbarRef} from './tiny/toolbar/constants';import picker from './tiny/toolbar/picker';-import { useEditorTags } from './useEditorTags';+import {useEditorTags} from './useEditorTags';const EditorHeader = () => {const [state] = useTracked();@@ -113,7 +113,9 @@ const EditorHeader = () => {undo: 0,redo: 0});- useEditorStore.getState().setCurrentlyEditingNote(null);+ setTimeout(() => {+ useEditorStore.getState().setCurrentlyEditingNote(null);+ }, 1);keyboardListener.current?.remove();await clearEditor(true, true, true);}diff --git a/apps/mobile/src/views/Editor/EditorWrapper.js b/apps/mobile/src/views/Editor/EditorWrapper.jsindex 9d4f1b533..e3f6417aa 100644--- a/apps/mobile/src/views/Editor/EditorWrapper.js+++ b/apps/mobile/src/views/Editor/EditorWrapper.js@@ -1,108 +1,21 @@-import React, {useEffect} from 'react';-import {- KeyboardAvoidingView,- Platform,- SafeAreaView,- TextInput,- View-} from 'react-native';-import {PanGestureHandler, State} from 'react-native-gesture-handler';-import Animated, {Easing} from 'react-native-reanimated';+import React from 'react';+import {TextInput, View} from 'react-native';import {useSafeAreaInsets} from 'react-native-safe-area-context';import Editor from '.';import {PremiumToast} from '../../components/Premium/premium-toast';-import Paragraph from '../../components/Typography/Paragraph';import {useTracked} from '../../provider';import {useNoteStore, useSettingStore} from '../../provider/stores';import {DDS} from '../../services/DeviceDetection';-import {eSendEvent} from '../../services/EventManager';-import {eOnLoadNote} from '../../utils/Events';import {editorRef} from '../../utils/Refs';-import useIsFloatingKeyboard from '../../utils/use-is-floating-keyboard';import EditorOverlay from './EditorOverlay';import {textInput} from './Functions';-let prevVal = 0;-let finalValue = 80;-let anim2 = new Animated.Value(0);-const op1 = new Animated.Value(1);-const op2 = new Animated.Value(0);-const op3 = new Animated.Value(0);--const onHandlerStateChange = evt => {- console.log('handler here');- if (evt.nativeEvent.state === State.END) {- if (evt.nativeEvent.translationY >= finalValue) {- eSendEvent(eOnLoadNote, {type: 'new'});- opacityAnim(0, 1, 0);- setTimeout(() => {- animation(0);- setTimeout(() => {- opacityAnim(1, 0, 0);- }, 150);- }, 200);- } else {- animation(0);- setTimeout(() => {- opacityAnim(1, 0, 0);- }, 150);- }- }-};--const onGestureEvent = event => {- console.log('gesture event');- if (event.nativeEvent.translationY < 0) return;-- let v = event.nativeEvent.translationY;- if (v >= 80 && prevVal !== 80) {- prevVal = 80;- animation(80);- opacityAnim(0, 0, 1);-- return;- }- if (v >= 80) return;- prevVal = v;- anim2.setValue(v);-};--function animation(a) {- Animated.timing(anim2, {- toValue: a,- duration: 150,- easing: Easing.inOut(Easing.ease)- }).start();-}--function opacityAnim(a, b, c) {- Animated.timing(op1, {- toValue: a,- duration: 50,- easing: Easing.inOut(Easing.ease)- }).start();- Animated.timing(op2, {- toValue: b,- duration: 300,- easing: Easing.inOut(Easing.ease)- }).start();- Animated.timing(op3, {- toValue: c,- duration: 300,- easing: Easing.inOut(Easing.ease)- }).start();-}--const AnimatedKeyboardView =- Animated.createAnimatedComponent(KeyboardAvoidingView);export const EditorWrapper = ({width, dimensions}) => {const [state] = useTracked();const {colors} = state;const deviceMode = useSettingStore(state => state.deviceMode);const loading = useNoteStore(state => state.loading);-const insets = useSafeAreaInsets();- const floating = useIsFloatingKeyboard();return (<View@@ -112,92 +25,19 @@ export const EditorWrapper = ({width, dimensions}) => {height: '100%',backgroundColor: state.colors.bg,borderLeftWidth: 1,- borderLeftColor: DDS.isTab ? colors.nav : 'transparent'+ borderLeftColor: DDS.isTab ? colors.nav : 'transparent',+ paddingTop:insets.top,+ paddingBottom:insets.bottom}}>- <SafeAreaView- style={{- width: '100%',- height: '100%'- }}>- <PremiumToast context="editor" offset={50 + insets.top} />- <View- style={{- position: 'absolute',- zIndex: 20,- height: insets.top,- top: 0,- width: dimensions.width,- backgroundColor: colors.bg- }}- />- <PanGestureHandler- minPointers={2}- onHandlerStateChange={onHandlerStateChange}- onGestureEvent={onGestureEvent}>- <AnimatedKeyboardView- behavior="padding"- enabled={!floating && Platform.OS === 'ios'}- style={{- transform: [- {- translateY: anim2- }- ],- height: '100%',- width: '100%'- }}>- <View- style={{- height: 80,- position: 'absolute',- backgroundColor: colors.accent,- width: '100%',- justifyContent: 'center',- alignItems: 'center',- zIndex: 10,- transform: [- {- translateY: Platform.OS === 'ios' ? -80 : -80 + insets.top- }- ]- }}>- <Animated.Text- style={{- position: 'absolute',- opacity: op1,- bottom: 10- }}>- <Paragraph color="white">- Keep swiping down to start a new note.- </Paragraph>- </Animated.Text>-- <Animated.Text- style={{- position: 'absolute',- opacity: op3- }}>- <Paragraph color="white">Release to load new note</Paragraph>- </Animated.Text>-- <Animated.Text- style={{- position: 'absolute',- opacity: op2- }}>- <Paragraph color="white">Loading a new note</Paragraph>- </Animated.Text>- </View>- <TextInput- ref={textInput}- style={{height: 1, padding: 0, width: 1, position: 'absolute'}}- blurOnSubmit={false}- />- {loading ? null : <Editor />}- <EditorOverlay />- </AnimatedKeyboardView>- </PanGestureHandler>- </SafeAreaView>+ <PremiumToast key="toast" context="editor" offset={50 + insets.top} />+ <TextInput+ key="input"+ ref={textInput}+ style={{height: 1, padding: 0, width: 1, position: 'absolute'}}+ blurOnSubmit={false}+ />+ {loading ? null : <Editor key="editor" />}+ <EditorOverlay key="overlay" /></View>);};