pass powerlevels state to power level section and admin section

pull/21833/head
Bruno Windels 2019-11-15 15:13:22 +01:00
parent bd853b3102
commit e86ceb986f
1 changed files with 6 additions and 6 deletions

View File

@ -628,13 +628,12 @@ const MuteToggleButton = withLegacyMatrixClient(
); );
const RoomAdminToolsContainer = withLegacyMatrixClient( const RoomAdminToolsContainer = withLegacyMatrixClient(
({matrixClient: cli, room, children, member, startUpdating, stopUpdating}) => { ({matrixClient: cli, room, children, member, startUpdating, stopUpdating, powerLevels}) => {
let kickButton; let kickButton;
let banButton; let banButton;
let muteButton; let muteButton;
let redactButton; let redactButton;
const powerLevels = useRoomPowerLevels(room);
const editPowerLevel = ( const editPowerLevel = (
(powerLevels.events ? powerLevels.events["m.room.power_levels"] : null) || (powerLevels.events ? powerLevels.events["m.room.power_levels"] : null) ||
powerLevels.state_default powerLevels.state_default
@ -837,8 +836,7 @@ function useRoomPermissions(cli, room, user) {
return roomPermissions; return roomPermissions;
} }
const PowerLevelEditor = withLegacyMatrixClient(({matrixClient: cli, user, room, startUpdating, stopUpdating, roomPermissions}) => { const PowerLevelSection = withLegacyMatrixClient(({matrixClient: cli, user, room, roomPermissions, powerLevels}) => {
const onPowerChange = useCallback(async (powerLevel) => {
const _applyPowerChange = (roomId, target, powerLevel, powerLevelEvent) => { const _applyPowerChange = (roomId, target, powerLevel, powerLevelEvent) => {
startUpdating(); startUpdating();
cli.setPowerLevel(roomId, target, parseInt(powerLevel), powerLevelEvent).then( cli.setPowerLevel(roomId, target, parseInt(powerLevel), powerLevelEvent).then(
@ -945,6 +943,7 @@ const UserInfo = withLegacyMatrixClient(({matrixClient: cli, user, groupId, room
// only display the devices list if our client supports E2E // only display the devices list if our client supports E2E
const _enableDevices = cli.isCryptoEnabled(); const _enableDevices = cli.isCryptoEnabled();
const powerLevels = useRoomPowerLevels(cli, room);
// Load whether or not we are a Synapse Admin // Load whether or not we are a Synapse Admin
const isSynapseAdmin = useIsSynapseAdmin(cli); const isSynapseAdmin = useIsSynapseAdmin(cli);
@ -1040,6 +1039,7 @@ const UserInfo = withLegacyMatrixClient(({matrixClient: cli, user, groupId, room
if (room && user.roomId) { if (room && user.roomId) {
adminToolsContainer = ( adminToolsContainer = (
<RoomAdminToolsContainer <RoomAdminToolsContainer
powerLevels={powerLevels}
member={user} member={user}
room={room} room={room}
startUpdating={startUpdating} startUpdating={startUpdating}
@ -1130,9 +1130,9 @@ const UserInfo = withLegacyMatrixClient(({matrixClient: cli, user, groupId, room
title={_t('Close')} />; title={_t('Close')} />;
} }
const memberDetails = <PowerLevelEditor const memberDetails = <PowerLevelSection
powerLevels={powerLevels}
user={user} room={room} roomPermissions={roomPermissions} user={user} room={room} roomPermissions={roomPermissions}
startUpdating={startUpdating} stopUpdating={stopUpdating}
/>; />;
const isRoomEncrypted = useIsEncrypted(cli, room); const isRoomEncrypted = useIsEncrypted(cli, room);