Fixed some granted value bugs within the PermissionEditor.tsx

canary
WolverinDEV 2020-06-28 14:40:30 +02:00
parent e84a4dcaf0
commit 4365e03dbe
1 changed files with 5 additions and 1 deletions

View File

@ -274,6 +274,7 @@ const PermissionEntryRow = (props: {
const [ flagSkip, setFlagSkip ] = useState(props.value.flagSkip);
const [ granted, setGranted ] = useState(props.value.granted);
const [ forceGrantedUpdate, setForceGrantedUpdate ] = useState(false);
const [ grantedEditing, setGrantedEditing ] = useState(false);
const [ grantedApplying, setGrantedApplying ] = useState(false);
@ -346,15 +347,17 @@ const PermissionEntryRow = (props: {
if(typeof granted === "undefined")
return;
setForceGrantedUpdate(true);
props.events.fire("action_remove_permissions", { permissions: [{ name: props.permission, mode: "grant" }] });
} else {
const numberValue = parseInt(newValue);
if(isNaN(numberValue)) return;
if(numberValue === granted) {
if(numberValue === granted && !forceGrantedUpdate) {
/* no change */
return;
}
setForceGrantedUpdate(true);
props.events.fire("action_set_permissions", { permissions: [{ name: props.permission, mode: "grant", value: numberValue }]});
}
}} onChange={() => {}} onKeyPress={e => e.key === "Enter" && e.currentTarget.blur()} />;
@ -368,6 +371,7 @@ const PermissionEntryRow = (props: {
if(event.target === "grant") {
setGranted(event.defaultValue);
setGrantedEditing(true);
setForceGrantedUpdate(true);
} else {
if(isBoolPermission && typeof value === "undefined") {
setValue(event.defaultValue >= 1 ? 1 : 0);