mobile: fix image replaces content if note is locked

& app lock is also enabled
This commit is contained in:
ammarahm-ed
2023-06-16 10:02:03 +05:00
committed by Ammar Ahmed
parent 574c4cc8a9
commit a3988fd309
3 changed files with 15 additions and 5 deletions

View File

@@ -35,6 +35,7 @@ export type EditorState = {
keyboardState: boolean;
ready: boolean;
saveCount: 0;
isAwaitingResult: boolean;
};
export type Settings = {

View File

@@ -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 =

View File

@@ -206,7 +206,6 @@ export const useEditor = (
type: type
};
}
if (!locked) {
id = await db.notes?.add(noteData);
if (!note && id) {