Show 'checkmark' icon when saved in editor

This commit is contained in:
Tom Moor
2017-07-11 23:24:12 -07:00
parent fb5d461c2b
commit 8ddc3fdf10
6 changed files with 73 additions and 18 deletions

View File

@ -37,6 +37,7 @@ type Props = {
@observer class DocumentScene extends Component {
props: Props;
savedTimeout: number;
state: {
newDocument?: Document,
};
@ -44,6 +45,7 @@ type Props = {
isDragging: false,
isLoading: false,
newDocument: undefined,
showAsSaved: false,
};
componentDidMount() {
@ -108,9 +110,19 @@ type Props = {
if (redirect || this.props.newDocument) {
this.props.history.push(document.url);
} else {
this.showAsSaved();
}
};
showAsSaved() {
this.setState({ showAsSaved: true });
this.savedTimeout = setTimeout(
() => this.setState({ showAsSaved: false }),
2000
);
}
onImageUploadStart() {
this.setState({ isLoading: true });
}
@ -204,6 +216,7 @@ type Props = {
<HeaderAction>
{isEditing
? <SaveAction
showCheckmark={this.state.showAsSaved}
onClick={this.onSave.bind(this, true)}
disabled={get(this.document, 'isSaving')}
isNew={!!isNew}