diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index 49903a4b2..3fcdcc168 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -64,7 +64,8 @@ const EditPage = createClass({ htmlErrors : Markdown.validate(this.props.brew.text), url : '', autoSave : true, - autoSaveWarning : false + autoSaveWarning : false, + unsavedTime : new Date() }; }, savedBrew : null, @@ -74,6 +75,7 @@ const EditPage = createClass({ url : window.location.href }); + this.savedBrew = JSON.parse(JSON.stringify(this.props.brew)); //Deep copy this.setState({ autoSave: JSON.parse(localStorage.getItem('AUTOSAVE_ON')) }, ()=>{ @@ -230,8 +232,9 @@ const EditPage = createClass({ editId : this.savedBrew.editId, shareId : this.savedBrew.shareId }, - isPending : false, - isSaving : false, + isPending : false, + isSaving : false, + unsavedTime : new Date() })); }, @@ -339,13 +342,14 @@ const EditPage = createClass({ } if(this.state.autoSaveWarning){ + console.log(this.state.unsavedTime); setTimeout(()=>this.setState({ autoSaveWarning: false }), 4000); this.setAutosaveWarning(); return Reminder...
- Autosave has been turned off, and you haven't saved for {Math.round((new Date() - new Date(this.props.brew.updatedAt)) / 1000 / 60)} minutes. + Autosave has been turned off, and you haven't saved for {Math.round((new Date() - this.state.unsavedTime) / 1000 / 60)} minutes.
; }