Addressed comments
This commit is contained in:
@ -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 */
|
||||
|
@ -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>}
|
||||
|
Reference in New Issue
Block a user