0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-15 06:12:43 +00:00

autosave warning conditional on elapsed time unsaved.

This commit is contained in:
Gazook89
2022-09-30 12:20:59 -05:00
parent 8609026531
commit bfb82e8a21

View File

@@ -342,14 +342,14 @@ const EditPage = createClass({
} }
if(this.state.autoSaveWarning){ if(this.state.autoSaveWarning){
console.log(this.state.unsavedTime);
setTimeout(()=>this.setState({ autoSaveWarning: false }), 4000);
this.setAutosaveWarning(); this.setAutosaveWarning();
const elapsedTime = Math.round((new Date() - this.state.unsavedTime) / 1000 / 60);
const text = elapsedTime == 0 ? 'Autosave is OFF.' : `Autosave has been turned off, and you haven't saved for ${elapsedTime} minutes.`;
return <Nav.item className='save error' icon='fas fa-exclamation-circle'> return <Nav.item className='save error' icon='fas fa-exclamation-circle'>
Reminder... Reminder...
<div className='errorContainer'> <div className='errorContainer'>
Autosave has been turned off, and you haven't saved for {Math.round((new Date() - this.state.unsavedTime) / 1000 / 60)} minutes. {text}
</div> </div>
</Nav.item>; </Nav.item>;
} }
@@ -379,6 +379,7 @@ const EditPage = createClass({
}, },
setAutosaveWarning : function(){ setAutosaveWarning : function(){
setTimeout(()=>this.setState({ autoSaveWarning: false }), 4000);
this.warningTimer = setTimeout(()=>{this.setState({ autoSaveWarning: true });}, 15000); this.warningTimer = setTimeout(()=>{this.setState({ autoSaveWarning: true });}, 15000);
this.warningTimer; this.warningTimer;
}, },