Skip to content

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

fix content from append is replaced in editor if note is already opened.

ammarahm-edb8a5e6ef0bb5
diff --git a/apps/mobile/src/utils/useAppEvents.js b/apps/mobile/src/utils/useAppEvents.js
index 7f719e64d..10046995b 100644
--- a/apps/mobile/src/utils/useAppEvents.js
+++ b/apps/mobile/src/utils/useAppEvents.js
@@ -1,6 +1,6 @@
import NetInfo from '@react-native-community/netinfo';
-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 {
Appearance,
AppState,
@@ -12,10 +12,10 @@ import {
} from 'react-native';
import RNExitApp from 'react-native-exit-app';
import * as RNIap from 'react-native-iap';
-import { enabled } from 'react-native-privacy-snapshot';
+import {enabled} from 'react-native-privacy-snapshot';
import SplashScreen from 'react-native-splash-screen';
-import { doInBackground, editing } from '.';
-import { ProFeatures } from '../components/ResultDialog/pro-features';
+import {doInBackground, editing} from '.';
+import {ProFeatures} from '../components/ResultDialog/pro-features';
import {
clearAllStores,
initialize,
@@ -49,16 +49,17 @@ import {
updateNoteInEditor
} from '../views/Editor/Functions';
import tiny from '../views/Editor/tiny/tiny';
-import { updateStatusBarColor } from './Colors';
-import { db } from './database';
+import {updateStatusBarColor} from './Colors';
+import {db} from './database';
import {
eClearEditor,
eCloseProgressDialog,
- eOpenLoginDialog, refreshNotesPage
+ eOpenLoginDialog,
+ refreshNotesPage
} from './Events';
-import { MMKV } from './mmkv';
+import {MMKV} from './mmkv';
import Storage from './storage';
-import { sleep } from './TimeUtils';
+import {sleep} from './TimeUtils';
const SodiumEventEmitter = new NativeEventEmitter(NativeModules.Sodium);
@@ -559,7 +560,7 @@ export const useAppEvents = () => {
eSendEvent(refreshNotesPage);
}
if (notesAddedFromIntent || shareExtensionOpened) {
- eSendEvent('webviewreset');
+ eSendEvent('webviewreset', true);
MMKV.removeItem('shareExtensionOpened');
}
} catch (e) {
diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.js
index 197bfda9c..7ff023ff0 100644
--- a/apps/mobile/src/views/Editor/Functions.js
+++ b/apps/mobile/src/views/Editor/Functions.js
@@ -180,6 +180,11 @@ export function setNoteOnly(n) {
note = n;
}
+export function disableEditing() {
+ noteEdited = false;
+ disableSaving = true;
+}
+
export const textInput = createRef();
export function post(type, value = null) {
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index 52fd4edcb..1f61d6ccc 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -15,6 +15,7 @@ import {sleep} from '../../utils/TimeUtils';
import EditorHeader from './EditorHeader';
import {
checkStatus,
+ disableEditing,
EditorWebView,
getNote,
onWebViewLoad,
@@ -50,7 +51,7 @@ const Editor = React.memo(
}
}, [premiumUser]);
- const onResetRequested = async noload => {
+ const onResetRequested = async preventSave => {
if (!getNote()) {
eSendEvent('loadingNote', null);
}
@@ -61,7 +62,12 @@ const Editor = React.memo(
console.log('Editor out of bounds');
return;
}
+ if (preventSave) {
+ disableEditing();
+ }
+
if (getNote()) {
+
eSendEvent(
eOnLoadNote,
{...getNote(), forced: true}
@@ -131,7 +137,7 @@ const Editor = React.memo(
allowUniversalAccessFromFileURLs={true}
originWhitelist={['*']}
source={source}
- //source={{uri: 'http://192.168.10.7:3000/index.html'}}
+ //source={{uri: 'http://192.168.10.13:3000/index.html'}}
style={style}
autoManageStatusBarEnabled={false}
onMessage={_onMessage}