Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Reduce excessive requests
Browse files Browse the repository at this point in the history
  • Loading branch information
maakbaas committed Apr 29, 2021
1 parent 7469a98 commit b2bf375
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 103 deletions.
6 changes: 4 additions & 2 deletions gui/js/comp/ControlItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export function ControlItem(props) {
setSaved(0);
setTarget(null);
}
});

useEffect(() => {
if (saving && target != null) {
const sizes = binsize(props.name, Dash);
const binData = new ArrayBuffer(sizes[1]);
Expand Down Expand Up @@ -70,7 +72,7 @@ export function ControlItem(props) {
});
setSaved(true);
}
});
}, [saving, target]);

function save() {
setSaving(1);
Expand All @@ -89,7 +91,7 @@ export function ControlItem(props) {
}}><Upload /></Button>;
}

return <><input onChange={(e) => { if (checkbox) { setTarget(e.target.checked); save(); } else { setTarget(e.target.value); } }} type={props.type} id={props.name} name={props.name} value={data} {...props.conditionalAttributes} />{savebtn}</>;
return <><input onClick={(e) => { if (checkbox) { setTarget(e.target.checked); save(); } else { setTarget(e.target.value); } }} type={props.type} id={props.name} name={props.name} value={data} {...props.conditionalAttributes} />{savebtn}</>;
}

ControlItem.propTypes = {
Expand Down
Loading

0 comments on commit b2bf375

Please sign in to comment.