mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +01:00
fix backhandler is not removed when move away from editor
This commit is contained in:
@@ -48,7 +48,7 @@ const onChangeTab = async (obj) => {
|
|||||||
currentTab = 1;
|
currentTab = 1;
|
||||||
activateKeepAwake();
|
activateKeepAwake();
|
||||||
eSendEvent('navigate');
|
eSendEvent('navigate');
|
||||||
|
eSendEvent(eClearEditor, 'addHandler');
|
||||||
if (!editing.currentlyEditing || !getNote()) {
|
if (!editing.currentlyEditing || !getNote()) {
|
||||||
eSendEvent(eOnLoadNote, {type: 'new'});
|
eSendEvent(eOnLoadNote, {type: 'new'});
|
||||||
editing.currentlyEditing = true;
|
editing.currentlyEditing = true;
|
||||||
@@ -60,6 +60,7 @@ const onChangeTab = async (obj) => {
|
|||||||
if (obj.from === 1) {
|
if (obj.from === 1) {
|
||||||
updateStatusBarColor();
|
updateStatusBarColor();
|
||||||
deactivateKeepAwake();
|
deactivateKeepAwake();
|
||||||
|
eSendEvent(eClearEditor, 'removeHandler');
|
||||||
if (getNote()?.locked) {
|
if (getNote()?.locked) {
|
||||||
eSendEvent(eClearEditor);
|
eSendEvent(eClearEditor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import {
|
|||||||
saveNote,
|
saveNote,
|
||||||
setIntent,
|
setIntent,
|
||||||
} from './Functions';
|
} from './Functions';
|
||||||
import { toolbarRef } from './tiny/toolbar/constants';
|
import {toolbarRef} from './tiny/toolbar/constants';
|
||||||
|
|
||||||
let handleBack;
|
let handleBack;
|
||||||
let tapCount = 0;
|
let tapCount = 0;
|
||||||
@@ -67,7 +67,6 @@ const EditorRoot = () => {
|
|||||||
await loadNote(item);
|
await loadNote(item);
|
||||||
InteractionManager.runAfterInteractions(() => {
|
InteractionManager.runAfterInteractions(() => {
|
||||||
Keyboard.addListener('keyboardDidShow', () => {
|
Keyboard.addListener('keyboardDidShow', () => {
|
||||||
|
|
||||||
if (!editing.movedAway) {
|
if (!editing.movedAway) {
|
||||||
editing.isFocused = true;
|
editing.isFocused = true;
|
||||||
}
|
}
|
||||||
@@ -82,7 +81,26 @@ const EditorRoot = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onCallClear = async () => {
|
const onCallClear = async (value) => {
|
||||||
|
if (value === 'removeHandler') {
|
||||||
|
if (handleBack) {
|
||||||
|
handleBack.remove();
|
||||||
|
handleBack = null;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (value === 'addHandler') {
|
||||||
|
if (handleBack) {
|
||||||
|
handleBack.remove();
|
||||||
|
handleBack = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleBack = BackHandler.addEventListener(
|
||||||
|
'hardwareBackPress',
|
||||||
|
_onHardwareBackPress,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (editing.currentlyEditing) {
|
if (editing.currentlyEditing) {
|
||||||
await _onBackPress();
|
await _onBackPress();
|
||||||
}
|
}
|
||||||
@@ -96,12 +114,12 @@ const EditorRoot = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const _onBackPress = async () => {
|
const _onBackPress = async () => {
|
||||||
eSendEvent("showTooltip");
|
eSendEvent('showTooltip');
|
||||||
toolbarRef.current?.scrollTo({
|
toolbarRef.current?.scrollTo({
|
||||||
x:0,
|
x: 0,
|
||||||
y:0,
|
y: 0,
|
||||||
animated:false
|
animated: false,
|
||||||
})
|
});
|
||||||
editing.currentlyEditing = false;
|
editing.currentlyEditing = false;
|
||||||
if (DDS.isLargeTablet()) {
|
if (DDS.isLargeTablet()) {
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
|
|||||||
Reference in New Issue
Block a user