mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 14:39:34 +01:00
release backhandler when move away from editor
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { Keyboard, Platform, View } from 'react-native';
|
import { Keyboard, Platform, View } from 'react-native';
|
||||||
import RNExitApp from 'react-native-exit-app';
|
|
||||||
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||||
import { notesnook } from '../../../e2e/test.ids';
|
import { notesnook } from '../../../e2e/test.ids';
|
||||||
import { ActionIcon } from '../../components/ActionIcon';
|
import { ActionIcon } from '../../components/ActionIcon';
|
||||||
@@ -13,9 +12,9 @@ import {editing} from '../../utils';
|
|||||||
import { db } from '../../utils/DB';
|
import { db } from '../../utils/DB';
|
||||||
import {
|
import {
|
||||||
eCloseFullscreenEditor,
|
eCloseFullscreenEditor,
|
||||||
eOpenFullscreenEditor,
|
eOpenFullscreenEditor
|
||||||
} from '../../utils/Events';
|
} from '../../utils/Events';
|
||||||
import {sideMenuRef, tabBarRef} from '../../utils/Refs';
|
import { tabBarRef } from '../../utils/Refs';
|
||||||
import { sleep } from '../../utils/TimeUtils';
|
import { sleep } from '../../utils/TimeUtils';
|
||||||
import { EditorTitle } from './EditorTitle';
|
import { EditorTitle } from './EditorTitle';
|
||||||
import {
|
import {
|
||||||
@@ -26,17 +25,13 @@ import {
|
|||||||
isNotedEdited,
|
isNotedEdited,
|
||||||
loadNote,
|
loadNote,
|
||||||
post,
|
post,
|
||||||
saveNote,
|
|
||||||
setColors,
|
setColors
|
||||||
setIntent,
|
|
||||||
} from './Functions';
|
} from './Functions';
|
||||||
import HistoryComponent from './HistoryComponent';
|
import HistoryComponent from './HistoryComponent';
|
||||||
import tiny from './tiny/tiny';
|
import tiny from './tiny/tiny';
|
||||||
import { toolbarRef } from './tiny/toolbar/constants';
|
import { toolbarRef } from './tiny/toolbar/constants';
|
||||||
|
|
||||||
let handleBack;
|
|
||||||
let tapCount = 0;
|
|
||||||
|
|
||||||
const EditorHeader = () => {
|
const EditorHeader = () => {
|
||||||
const [state] = useTracked();
|
const [state] = useTracked();
|
||||||
const {colors, fullscreen, deviceMode} = state;
|
const {colors, fullscreen, deviceMode} = state;
|
||||||
@@ -81,10 +76,7 @@ const EditorHeader = () => {
|
|||||||
}
|
}
|
||||||
post('keyboard');
|
post('keyboard');
|
||||||
});
|
});
|
||||||
if (handleBack) {
|
|
||||||
handleBack.remove();
|
|
||||||
handleBack = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -115,6 +107,8 @@ const EditorHeader = () => {
|
|||||||
await _onBackPress();
|
await _onBackPress();
|
||||||
Navigation.popToTop();
|
Navigation.popToTop();
|
||||||
}}
|
}}
|
||||||
|
top={50}
|
||||||
|
left={50}
|
||||||
testID={notesnook.ids.default.header.buttons.back}
|
testID={notesnook.ids.default.header.buttons.back}
|
||||||
name="arrow-left"
|
name="arrow-left"
|
||||||
color={colors.heading}
|
color={colors.heading}
|
||||||
@@ -140,6 +134,7 @@ const EditorHeader = () => {
|
|||||||
marginLeft: 10,
|
marginLeft: 10,
|
||||||
borderRadius: 5,
|
borderRadius: 5,
|
||||||
}}
|
}}
|
||||||
|
top={50}
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
await loadNote({type: 'new'});
|
await loadNote({type: 'new'});
|
||||||
}}
|
}}
|
||||||
@@ -152,6 +147,7 @@ const EditorHeader = () => {
|
|||||||
customStyle={{
|
customStyle={{
|
||||||
marginLeft: 10,
|
marginLeft: 10,
|
||||||
}}
|
}}
|
||||||
|
top={50}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
eSendEvent(eOpenFullscreenEditor);
|
eSendEvent(eOpenFullscreenEditor);
|
||||||
editing.isFullscreen = true;
|
editing.isFullscreen = true;
|
||||||
@@ -166,6 +162,8 @@ const EditorHeader = () => {
|
|||||||
customStyle={{
|
customStyle={{
|
||||||
marginLeft: 10,
|
marginLeft: 10,
|
||||||
}}
|
}}
|
||||||
|
top={50}
|
||||||
|
right={50}
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
let note = getNote() && db.notes.note(getNote().id).data;
|
let note = getNote() && db.notes.note(getNote().id).data;
|
||||||
if (editing.isFocused) {
|
if (editing.isFocused) {
|
||||||
|
|||||||
Reference in New Issue
Block a user