From 9bb13445389ea799e85736fec1ebaeaefbae9b21 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Wed, 28 Sep 2022 12:17:14 -0500 Subject: [PATCH] tweak behavior per calculuschild notes Default to autosave = true. trySave() when autosave toggled on. Display "auto-saved." when save is a result of autosave. --- client/homebrew/pages/editPage/editPage.jsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index fa755aa5d..f3fad3f53 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -63,7 +63,7 @@ const EditPage = createClass({ errors : null, htmlErrors : Markdown.validate(this.props.brew.text), url : '', - autoSave : null + autoSave : true }; }, savedBrew : null, @@ -339,6 +339,9 @@ const EditPage = createClass({ if(this.state.isPending && this.hasChanges()){ return Save Now; } + if(!this.state.isPending && !this.state.isSaving && this.state.autoSave){ + return auto-saved.; + } if(!this.state.isPending && !this.state.isSaving){ return saved.; } @@ -347,8 +350,10 @@ const EditPage = createClass({ handleAutoSave : function(){ this.setState((prevState)=>({ autoSave : !prevState.autoSave - })); - localStorage.setItem('AUTOSAVE_ON', JSON.stringify(!this.state.autoSave)); + }), ()=>{ + this.trySave(); + localStorage.setItem('AUTOSAVE_ON', JSON.stringify(this.state.autoSave)); + }); }, renderAutoSaveButton : function(){