add canEdit to permission state, more explicit than maxLevel >= 0

This commit is contained in:
Bruno Windels 2019-11-15 15:18:04 +01:00
parent 48b1207c6e
commit 264c8181c2

View file

@ -786,7 +786,7 @@ function useRoomPermissions(cli, room, user) {
const [roomPermissions, setRoomPermissions] = useState({ const [roomPermissions, setRoomPermissions] = useState({
// modifyLevelMax is the max PL we can set this user to, typically min(their PL, our PL) && canSetPL // modifyLevelMax is the max PL we can set this user to, typically min(their PL, our PL) && canSetPL
modifyLevelMax: -1, modifyLevelMax: -1,
canAffectUser: false, canEdit: false,
canInvite: false, canInvite: false,
}); });
const updateRoomPermissions = useCallback(async () => { const updateRoomPermissions = useCallback(async () => {
@ -817,7 +817,7 @@ function useRoomPermissions(cli, room, user) {
setRoomPermissions({ setRoomPermissions({
canInvite: me.powerLevel >= powerLevels.invite, canInvite: me.powerLevel >= powerLevels.invite,
canAffectUser, canEdit: modifyLevelMax >= 0,
modifyLevelMax, modifyLevelMax,
}); });
}, [cli, user, room]); }, [cli, user, room]);
@ -827,7 +827,7 @@ function useRoomPermissions(cli, room, user) {
return () => { return () => {
setRoomPermissions({ setRoomPermissions({
maximalPowerLevel: -1, maximalPowerLevel: -1,
canAffectUser: false, canEdit: false,
canInvite: false, canInvite: false,
}); });
}; };