diff --git a/src/components/structures/RightPanel.js b/src/components/structures/RightPanel.js index e7e8c3cf..0225f765 100644 --- a/src/components/structures/RightPanel.js +++ b/src/components/structures/RightPanel.js @@ -21,11 +21,12 @@ import PropTypes from 'prop-types'; import { _t } from 'matrix-react-sdk/lib/languageHandler'; import sdk from 'matrix-react-sdk'; import dis from 'matrix-react-sdk/lib/dispatcher'; -import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg'; +import MatrixClient from 'matrix-js-sdk'; import Analytics from 'matrix-react-sdk/lib/Analytics'; import rate_limited_func from 'matrix-react-sdk/lib/ratelimitedfunc'; import AccessibleButton from 'matrix-react-sdk/lib/components/views/elements/AccessibleButton'; import { showGroupInviteDialog, showGroupAddRoomDialog } from 'matrix-react-sdk/lib/GroupAddressPicker'; +import GroupStoreCache from 'matrix-react-sdk/lib/stores/GroupStoreCache'; class HeaderButton extends React.Component { constructor() { @@ -80,6 +81,10 @@ module.exports = React.createClass({ collapsed: React.PropTypes.bool, // currently unused property to request for a minimized view of the panel }, + contextTypes: { + matrixClient: PropTypes.instanceOf(MatrixClient), + }, + Phase: { RoomMemberList: 'RoomMemberList', GroupMemberList: 'GroupMemberList', @@ -92,14 +97,14 @@ module.exports = React.createClass({ componentWillMount: function() { this.dispatcherRef = dis.register(this.onAction); - const cli = MatrixClientPeg.get(); + const cli = this.context.matrixClient; cli.on("RoomState.members", this.onRoomStateMember); }, componentWillUnmount: function() { dis.unregister(this.dispatcherRef); - if (MatrixClientPeg.get()) { - MatrixClientPeg.get().removeListener("RoomState.members", this.onRoomStateMember); + if (this.context.matrixClient) { + this.context.matrixClient.removeListener("RoomState.members", this.onRoomStateMember); } }, @@ -122,7 +127,7 @@ module.exports = React.createClass({ }, onInviteButtonClick: function() { - if (MatrixClientPeg.get().isGuest()) { + if (this.context.matrixClient.isGuest()) { dis.dispatch({action: 'view_set_mxid'}); return; } @@ -222,13 +227,13 @@ module.exports = React.createClass({ if ((this.state.phase == this.Phase.RoomMemberList || this.state.phase === this.Phase.RoomMemberInfo) && this.props.roomId ) { - const cli = MatrixClientPeg.get(); + const cli = this.context.matrixClient; const room = cli.getRoom(this.props.roomId); let userIsInRoom; if (room) { membersBadge = room.getJoinedMembers().length; userIsInRoom = room.hasMembershipState( - MatrixClientPeg.get().credentials.userId, 'join', + this.context.matrixClient.credentials.userId, 'join', ); } @@ -317,7 +322,9 @@ module.exports = React.createClass({ panel =
; } - if (this.props.groupId) { + if (this.props.groupId && + GroupStoreCache.getGroupStore(this.context.matrixClient, this.props.groupId).isUserPrivileged() + ) { inviteGroup = [ this.Phase.GroupMemberInfo, this.Phase.GroupMemberList,