0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 22:52:40 +00:00

Shift manual save to use debounced save function

This commit is contained in:
G.Ambatte
2023-09-04 13:29:37 +12:00
parent 3ba15a068a
commit 93a93f1907

View File

@@ -91,7 +91,7 @@ const EditPage = createClass({
if(!(e.ctrlKey || e.metaKey)) return;
const S_KEY = 83;
const P_KEY = 80;
if(e.keyCode == S_KEY) this.save();
if(e.keyCode == S_KEY) this.trySave(true);
if(e.keyCode == P_KEY) window.open(`/print/${this.processShareId()}?dialog=true`, '_blank').focus();
if(e.keyCode == P_KEY || e.keyCode == S_KEY){
e.stopPropagation();
@@ -137,13 +137,14 @@ const EditPage = createClass({
return !_.isEqual(this.state.brew, this.savedBrew);
},
trySave : function(){
trySave : function(immediate=false){
if(!this.debounceSave) this.debounceSave = _.debounce(this.save, SAVE_TIMEOUT);
if(this.hasChanges()){
this.debounceSave();
} else {
this.debounceSave.cancel();
}
if(immediate) this.debounceSave.flush();
},
handleGoogleClick : function(){