Skip to content

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

fix: unable to focus editor in empty note

ammarahm-ed05e893b6a4a5
diff --git a/apps/mobile/html/Web.bundle/site/listeners.js b/apps/mobile/html/Web.bundle/site/listeners.js
index cc4c0738e..0a7e077e1 100755
--- a/apps/mobile/html/Web.bundle/site/listeners.js
+++ b/apps/mobile/html/Web.bundle/site/listeners.js
@@ -110,7 +110,9 @@ function autosize() {
function isInvalidValue(value) {
return (
+ !value ||
value === '' ||
+ value.trim() === "" ||
value === '<p></p>' ||
value === '<p><br></p>' ||
value === '<p>&nbsp;</p>'
diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.js
index eb3cb5b0c..0aedab265 100644
--- a/apps/mobile/src/views/Editor/Functions.js
+++ b/apps/mobile/src/views/Editor/Functions.js
@@ -400,6 +400,10 @@ function updateSessionStatus() {
);
}
+function isContentInvalid(content) {
+ return !content || content === '' || content.trim() === "" || content === '<p></p>' || content === '<p><br></p>' || content === '<p>&nbsp;</p>'
+}
+
function check_session_status() {
tiny.call(
EditorWebView,
@@ -409,7 +413,8 @@ function check_session_status() {
return;
}
editor.getHTML().then(function(value) {
- let status = value === '' || value === '<p></p>' || value === '<p><br></p>' || value === '<p>&nbsp;</p>';
+ let status = !value || value === '' || value.trim() === "" || value === '<p></p>' || value === '<p><br></p>' || value === '<p>&nbsp;</p>';
+
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: 'content_not_loaded',
@@ -530,16 +535,14 @@ export const _onMessage = async evt => {
break;
case 'content_not_loaded':
loading_note = false;
+ if (isContentInvalid(content.data)) return;
if (message.sessionId !== sessionId) {
requestedReload = true;
updateSessionStatus();
return;
}
- if (!id) {
- console.log('no note loaded', id);
- return;
- }
- console.log('content not loaded');
+ if (!id) return;
+ console.log('content not loaded',content.data);
if (message.value) {
console.log('reloading');
await loadNoteInEditor();