diff --git a/frontend/models/Document.js b/frontend/models/Document.js index db9bd6858..c2068c1f9 100644 --- a/frontend/models/Document.js +++ b/frontend/models/Document.js @@ -72,12 +72,13 @@ class Document { return []; } - @computed get allowSave(): boolean { + @computed get isEmpty(): boolean { // Check if the document title has been modified and user generated content exists - return ( - this.text.replace(new RegExp(`^\#$`), '').trim().length > 0 && - !this.isSaving - ); + return this.text.replace(new RegExp(`^\#$`), '').trim().length === 0; + } + + @computed get allowSave(): boolean { + return !this.isEmpty && !this.isSaving; } /* Actions */ diff --git a/frontend/scenes/Document/Document.js b/frontend/scenes/Document/Document.js index 2df164ce0..e81507dbb 100644 --- a/frontend/scenes/Document/Document.js +++ b/frontend/scenes/Document/Document.js @@ -104,7 +104,7 @@ type Props = { }; onSave = async (redirect: boolean = false) => { - if (!get(this.document, 'allowSave')) return; + if (this.document && !this.document.allowSave) return; let document = this.document; if (!document) return; @@ -221,7 +221,7 @@ type Props = { ? : Edit}