Skip to content

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

fix saving note

ammarahm-ed046b83262081
diff --git a/apps/mobile/NotesnookShare.js b/apps/mobile/NotesnookShare.js
index 7ac3eef71..799dec2be 100644
--- a/apps/mobile/NotesnookShare.js
+++ b/apps/mobile/NotesnookShare.js
@@ -71,7 +71,10 @@ export default class NotesnookShare extends Component {
let add = async () => {
await db.notes.add({
title: this.state.title,
- content: `<${tag}>${this.state.text}<${tag}/>`,
+ content: {
+ type:'tiny',
+ data:`<${tag}>${this.state.text}<${tag}/>`
+ },
id: null,
});
};
diff --git a/apps/mobile/android/app/src/main/assets/index.html b/apps/mobile/android/app/src/main/assets/index.html
index 26d389c25..857b32f90 100644
--- a/apps/mobile/android/app/src/main/assets/index.html
+++ b/apps/mobile/android/app/src/main/assets/index.html
@@ -1,6 +1,5 @@
<!DOCTYPE html>
<html>
-
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8" />
diff --git a/apps/mobile/android/app/src/main/assets/init.js b/apps/mobile/android/app/src/main/assets/init.js
index 304378751..6f6c639a4 100644
--- a/apps/mobile/android/app/src/main/assets/init.js
+++ b/apps/mobile/android/app/src/main/assets/init.js
@@ -12,6 +12,8 @@ function reactNativeEventHandler(type, value) {
}
let changeTimer = null;
+let isLoading = true;
+
function init_tiny(size) {
tinymce.init({
selector: '#tiny_textarea',
@@ -46,7 +48,12 @@ function init_tiny(size) {
reactNativeEventHandler('status', true);
editor.on('SelectionChange', function (e) {
clearTimeout(changeTimer);
+ if (isLoading) {
+ isLoading = false;
+ return;
+ }
changeTimer = setTimeout(() => {
+ if (editor.plugins.wordcount.getCount() === 0) return;
selectchange();
reactNativeEventHandler('tiny', editor.getContent());
reactNativeEventHandler('history', {
@@ -60,7 +67,13 @@ function init_tiny(size) {
});
editor.on('Change', function (e) {
clearTimeout(changeTimer);
+ if (isLoading) {
+ isLoading = false;
+ return;
+ }
+
changeTimer = setTimeout(() => {
+ if (editor.plugins.wordcount.getCount() === 0) return;
selectchange();
reactNativeEventHandler('tiny', editor.getContent());
reactNativeEventHandler('history', {
@@ -70,7 +83,7 @@ function init_tiny(size) {
}, 5);
});
editor.on('ExecCommand', function (e) {
- reactNativeEventHandler(e);
+ //reactNativeEventHandler(e);
});
},
});
diff --git a/apps/mobile/html/Web.bundle/site/init.js b/apps/mobile/html/Web.bundle/site/init.js
index 304378751..6f6c639a4 100644
--- a/apps/mobile/html/Web.bundle/site/init.js
+++ b/apps/mobile/html/Web.bundle/site/init.js
@@ -12,6 +12,8 @@ function reactNativeEventHandler(type, value) {
}
let changeTimer = null;
+let isLoading = true;
+
function init_tiny(size) {
tinymce.init({
selector: '#tiny_textarea',
@@ -46,7 +48,12 @@ function init_tiny(size) {
reactNativeEventHandler('status', true);
editor.on('SelectionChange', function (e) {
clearTimeout(changeTimer);
+ if (isLoading) {
+ isLoading = false;
+ return;
+ }
changeTimer = setTimeout(() => {
+ if (editor.plugins.wordcount.getCount() === 0) return;
selectchange();
reactNativeEventHandler('tiny', editor.getContent());
reactNativeEventHandler('history', {
@@ -60,7 +67,13 @@ function init_tiny(size) {
});
editor.on('Change', function (e) {
clearTimeout(changeTimer);
+ if (isLoading) {
+ isLoading = false;
+ return;
+ }
+
changeTimer = setTimeout(() => {
+ if (editor.plugins.wordcount.getCount() === 0) return;
selectchange();
reactNativeEventHandler('tiny', editor.getContent());
reactNativeEventHandler('history', {
@@ -70,7 +83,7 @@ function init_tiny(size) {
}, 5);
});
editor.on('ExecCommand', function (e) {
- reactNativeEventHandler(e);
+ //reactNativeEventHandler(e);
});
},
});
diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js
index c95e88f08..c04d5b89e 100644
--- a/apps/mobile/src/components/ActionSheetComponent/index.js
+++ b/apps/mobile/src/components/ActionSheetComponent/index.js
@@ -549,7 +549,7 @@ export const ActionSheetComponent = ({
{note.type === 'notebook' && note.description
? note.description
: null}
- {note.type === 'note'
+ {note.type === 'note' && item.headline
? note.headline[item.headline.length - 1] === '\n'
? note.headline.slice(0, note.headline.length - 1)
: note.headline
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index 7216d89ee..bf7e29c1a 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -128,11 +128,13 @@ export default class NoteItem extends React.Component {
{item.title.replace('\n', '')}
</Heading>
- <Paragraph numberOfLines={2}>
- {item.headline[item.headline.length - 1] === '\n'
- ? item.headline.slice(0, item.headline.length - 1)
- : item.headline}
- </Paragraph>
+ {item.headline && (
+ <Paragraph numberOfLines={2}>
+ {item.headline[item.headline.length - 1] === '\n'
+ ? item.headline.slice(0, item.headline.length - 1)
+ : item.headline}
+ </Paragraph>
+ )}
<View
style={{
diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.js
index d79cb4cf7..acc3de80a 100644
--- a/apps/mobile/src/views/Editor/Functions.js
+++ b/apps/mobile/src/views/Editor/Functions.js
@@ -238,8 +238,12 @@ export const _onMessage = async (evt) => {
case 'history':
eSendEvent('historyEvent', message.value);
break;
- case 'change':
- content = message;
+ case 'tiny':
+ console.log('change',message);
+ content = {
+ type:message.type,
+ data:message.value
+ };
onNoteChange();
break;
case 'title':
@@ -299,6 +303,7 @@ function onNoteChange() {
}
export async function clearEditor() {
+ tiny.call(EditorWebView,tiny.isLoading);
clearTimer();
tiny.call(EditorWebView, tiny.reset);
if (noteEdited && id) {
@@ -386,6 +391,8 @@ export async function saveNote() {
return;
}
let locked = id ? db.notes.note(id).data.locked : null;
+ console.log(content,"SAVE Content");
+
let noteData = {
title,
content: {
diff --git a/apps/mobile/src/views/Editor/tiny/tiny.js b/apps/mobile/src/views/Editor/tiny/tiny.js
index d5320f829..b69bb157c 100644
--- a/apps/mobile/src/views/Editor/tiny/tiny.js
+++ b/apps/mobile/src/views/Editor/tiny/tiny.js
@@ -103,7 +103,12 @@ const updateTheme = (value) => `
`;
+const isLoading =`
+isLoading = true;
+`;
+
const html = (value) => `
+isLoading = true;
editor.setContent("${value}");
info.querySelector('#infowords').innerText =
editor.plugins.wordcount.getCount() + " words";
@@ -151,5 +156,6 @@ export default {
updateSavingState,
updateTheme,
setTitle,
- restoreRange
+ restoreRange,
+ isLoading
};