mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-25 16:09:42 +01:00
mobile: fix image replaces content if note is locked
& app lock is also enabled
This commit is contained in:
@@ -35,6 +35,7 @@ export type EditorState = {
|
||||
keyboardState: boolean;
|
||||
ready: boolean;
|
||||
saveCount: 0;
|
||||
isAwaitingResult: boolean;
|
||||
};
|
||||
|
||||
export type Settings = {
|
||||
|
||||
@@ -248,8 +248,11 @@ export const useEditorEvents = (
|
||||
}
|
||||
});
|
||||
}, [onHardwareBackPress]);
|
||||
const onCallClear = useCallback(
|
||||
|
||||
const onClearEditorSessionRequest = useCallback(
|
||||
async (value: string) => {
|
||||
if (editorState()?.isAwaitingResult) return;
|
||||
|
||||
if (value === "removeHandler") {
|
||||
if (handleBack.current) {
|
||||
handleBack.current.remove();
|
||||
@@ -291,12 +294,15 @@ export const useEditorEvents = (
|
||||
|
||||
useEffect(() => {
|
||||
eSubscribeEvent(eOnLoadNote + editor.editorId, onLoadNote);
|
||||
eSubscribeEvent(eClearEditor + editor.editorId, onCallClear);
|
||||
eSubscribeEvent(
|
||||
eClearEditor + editor.editorId,
|
||||
onClearEditorSessionRequest
|
||||
);
|
||||
return () => {
|
||||
eUnSubscribeEvent(eClearEditor, onCallClear);
|
||||
eUnSubscribeEvent(eClearEditor, onClearEditorSessionRequest);
|
||||
eUnSubscribeEvent(eOnLoadNote, onLoadNote);
|
||||
};
|
||||
}, [editor.editorId, onCallClear, onLoadNote]);
|
||||
}, [editor.editorId, onClearEditorSessionRequest, onLoadNote]);
|
||||
|
||||
const onMessage = useCallback(
|
||||
(event: WebViewMessageEvent) => {
|
||||
@@ -374,8 +380,12 @@ export const useEditorEvents = (
|
||||
}
|
||||
break;
|
||||
case EventTypes.filepicker:
|
||||
editorState().isAwaitingResult = true;
|
||||
const { pick } = require("./picker.js").default;
|
||||
pick({ type: editorMessage.value });
|
||||
setTimeout(() => {
|
||||
editorState().isAwaitingResult = false;
|
||||
}, 1000);
|
||||
break;
|
||||
case EventTypes.download: {
|
||||
const downloadAttachment =
|
||||
|
||||
@@ -206,7 +206,6 @@ export const useEditor = (
|
||||
type: type
|
||||
};
|
||||
}
|
||||
|
||||
if (!locked) {
|
||||
id = await db.notes?.add(noteData);
|
||||
if (!note && id) {
|
||||
|
||||
Reference in New Issue
Block a user