Skip to content

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

make sure note loads if text is null

ammarahm-ed4e3eecdf730f
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index 3f4a6ab97..a6fc19725 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -260,7 +260,7 @@ const Editor = ({noMenu}) => {
delta: {ops: []},
};
}
-
+
return true;
};
@@ -385,52 +385,51 @@ const Editor = ({noMenu}) => {
};
const updateEditor = async () => {
+ title = note.title;
+ id = note.id;
+ saveCounter = 0;
+ InfoBarRef.current?.setDateCreated(note.dateCreated);
try {
- title = note.title;
- id = note.id;
- saveCounter = 0;
- InfoBarRef.current?.setDateCreated(note.dateCreated);
-
content.text = await db.notes.note(id).text();
-
InfoBarRef.current?.setDateEdited(
note.dateEdited,
content.text.split(' ').length,
);
- if (title !== null || title === '') {
- post({
- type: 'title',
- value: note.title,
- });
- } else {
- post({
- type: 'clearTitle',
- });
- post({
- type: 'clearEditor',
- });
- post({
- type: 'focusTitle',
- });
- }
- if (content.text === '' && note.content.delta === null) {
- post({
- type: 'clearEditor',
- });
- } else if (note.content.delta) {
- if (typeof note.content.delta !== 'string') {
- content.delta = note.content.delta;
- } else {
- content.delta = await db.notes.note(id).delta();
- }
- post({
- type: 'delta',
- value: content.delta,
- });
+ } catch (e) {}
+
+ if (title !== null || title === '') {
+ post({
+ type: 'title',
+ value: note.title,
+ });
+ } else {
+ post({
+ type: 'clearTitle',
+ });
+ post({
+ type: 'clearEditor',
+ });
+ post({
+ type: 'focusTitle',
+ });
+ }
+ if (content.text === '' && note.content.delta === null) {
+ post({
+ type: 'clearEditor',
+ });
+ } else if (note.content.delta) {
+ if (typeof note.content.delta !== 'string') {
+ content.delta = note.content.delta;
} else {
- post({type: 'text', value: content.text});
+ content.delta = await db.notes.note(id).delta();
}
- } catch (e) {}
+ post({
+ type: 'delta',
+ value: content.delta,
+ });
+ } else {
+ post({type: 'text', value: content.text});
+ }
};
const params = 'platform=' + Platform.OS;