Addressed comments

This commit is contained in:
Jori Lallo
2017-07-18 23:45:01 -07:00
parent b5a05be726
commit 1e8378abef
2 changed files with 8 additions and 7 deletions

View File

@ -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 */

View File

@ -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 = {
? <SaveAction
showCheckmark={this.state.showAsSaved}
onClick={this.onSave.bind(this, true)}
disabled={!get(this.document, 'allowSave')}
disabled={!(this.document && this.document.allowSave)}
isNew={!!isNew}
/>
: <a onClick={this.onClickEdit}>Edit</a>}