Skip to content

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

fix editor back press

ammarahm-edf41d1da0e24f
diff --git a/apps/mobile/src/views/Editor/EditorRoot.js b/apps/mobile/src/views/Editor/EditorRoot.js
index 2baa1f54f..d9e05cafa 100644
--- a/apps/mobile/src/views/Editor/EditorRoot.js
+++ b/apps/mobile/src/views/Editor/EditorRoot.js
@@ -107,41 +107,51 @@ const EditorRoot = () => {
}
};
+
const _onBackPress = async () => {
- eSendEvent('showTooltip');
- toolbarRef.current?.scrollTo({
- x: 0,
- y: 0,
- animated: false,
- });
- editing.currentlyEditing = false;
- if (DDS.isLargeTablet()) {
- if (fullscreen) {
- eSendEvent(eCloseFullscreenEditor);
- }
- } else {
- if (DDS.isPhone || DDS.isSmallTab) {
- tabBarRef.current?.goToPage(0);
- }
- eSendEvent('historyEvent', {
- undo: 0,
- redo: 0,
+ if (DDS.isTab && fullscreen) {
+ eSendEvent(eCloseFullscreenEditor);
+ return;
+ }
+ tiny.call(EditorWebView,tiny.blur);
+ setTimeout(async () => {
+ eSendEvent('showTooltip');
+ toolbarRef.current?.scrollTo({
+ x: 0,
+ y: 0,
+ animated: false,
});
+ editing.isFocused = false;
+ editing.currentlyEditing = false;
- if (checkNote() && isNotedEdited()) {
- ToastEvent.show({
- heading: 'Note Saved',
- type: 'success',
- duration:1500
+ if (DDS.isTab) {
+ if (fullscreen) {
+ eSendEvent(eCloseFullscreenEditor);
+ }
+ } else {
+ if (!DDS.isTab) {
+ tabBarRef.current?.goToPage(0);
+ }
+ eSendEvent('historyEvent', {
+ undo: 0,
+ redo: 0,
});
+
+ if (checkNote() && isNotedEdited()) {
+ ToastEvent.show({
+ heading: 'Note Saved',
+ type: 'success',
+ duration:1500
+ });
+ }
+ await clearEditor();
+ Keyboard.removeListener('keyboardDidShow', tiny.onKeyboardShow);
+ if (handleBack) {
+ handleBack.remove();
+ handleBack = null;
+ }
}
- await clearEditor();
- Keyboard.removeListener('keyboardDidShow', tiny.onKeyboardShow);
- if (handleBack) {
- handleBack.remove();
- handleBack = null;
- }
- }
+ }, 50);
};
return <></>;
diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.js
index 40dac3107..c5ff53ecf 100644
--- a/apps/mobile/src/views/Editor/Functions.js
+++ b/apps/mobile/src/views/Editor/Functions.js
@@ -398,17 +398,18 @@ function onNoteChange() {
}
export async function clearEditor() {
+ clearTimer();
try {
if (
(content?.data &&
typeof content.data == 'string' &&
content.data?.trim().length > 0) ||
- (title && title?.trim().length > 0)
+ (title && title?.trim().length > 0) &&
+ id
) {
await saveNote(true);
}
tiny.call(EditorWebView, tiny.reset, true);
- clearTimer();
clearNote();
editing.focusType = null;
eSendEvent('historyEvent', {