From 4365e03dbe93aae896210596cefc9cfbfec8d956 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sun, 28 Jun 2020 14:40:30 +0200 Subject: [PATCH] Fixed some granted value bugs within the PermissionEditor.tsx --- shared/js/ui/modal/permission/PermissionEditor.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shared/js/ui/modal/permission/PermissionEditor.tsx b/shared/js/ui/modal/permission/PermissionEditor.tsx index 6da47f1f..fbf60612 100644 --- a/shared/js/ui/modal/permission/PermissionEditor.tsx +++ b/shared/js/ui/modal/permission/PermissionEditor.tsx @@ -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);