Revert c082827fc7
Revert the WithMatrixClient change: RoomView calls methods on the RoomSettings component and this breaks when RoomSettings is wrapped in a WithMatrixClient.
This commit is contained in:
parent
c082827fc7
commit
a5a056292d
1 changed files with 25 additions and 31 deletions
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
|
||||
import q from 'q';
|
||||
import React from 'react';
|
||||
import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||
import SdkConfig from '../../../SdkConfig';
|
||||
import sdk from '../../../index';
|
||||
import Modal from '../../../Modal';
|
||||
|
@ -26,7 +27,6 @@ import ScalarAuthClient from '../../../ScalarAuthClient';
|
|||
import ScalarMessaging from '../../../ScalarMessaging';
|
||||
import UserSettingsStore from '../../../UserSettingsStore';
|
||||
import AccessibleButton from '../elements/AccessibleButton';
|
||||
import WithMatrixClient from '../../../wrappers/WithMatrixClient';
|
||||
|
||||
|
||||
// parse a string as an integer; if the input is undefined, or cannot be parsed
|
||||
|
@ -36,12 +36,9 @@ function parseIntWithDefault(val, def) {
|
|||
return isNaN(res) ? def : res;
|
||||
}
|
||||
|
||||
const BannedUser = WithMatrixClient(React.createClass({
|
||||
const BannedUser = React.createClass({
|
||||
propTypes: {
|
||||
/* MatrixClient instance */
|
||||
matrixClient: React.PropTypes.object.isRequired,
|
||||
|
||||
member: React.PropTypes.object.isRequired, // js-sdk member object
|
||||
member: React.PropTypes.string.isRequired,
|
||||
},
|
||||
|
||||
_onUnbanClick: function() {
|
||||
|
@ -53,7 +50,7 @@ const BannedUser = WithMatrixClient(React.createClass({
|
|||
onFinished: (proceed) => {
|
||||
if (!proceed) return;
|
||||
|
||||
this.props.matrixClient.unban(
|
||||
MatrixClientPeg.get().unban(
|
||||
this.props.member.roomId, this.props.member.userId,
|
||||
).catch((err) => {
|
||||
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||
|
@ -78,15 +75,12 @@ const BannedUser = WithMatrixClient(React.createClass({
|
|||
</li>
|
||||
);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
module.exports = WithMatrixClient(React.createClass({
|
||||
module.exports = React.createClass({
|
||||
displayName: 'RoomSettings',
|
||||
|
||||
propTypes: {
|
||||
/* MatrixClient instance */
|
||||
matrixClient: React.PropTypes.object.isRequired,
|
||||
|
||||
room: React.PropTypes.object.isRequired,
|
||||
onSaveClick: React.PropTypes.func,
|
||||
onCancelClick: React.PropTypes.func,
|
||||
|
@ -123,9 +117,9 @@ module.exports = WithMatrixClient(React.createClass({
|
|||
componentWillMount: function() {
|
||||
ScalarMessaging.startListening();
|
||||
|
||||
this.props.matrixClient.on("RoomMember.membership", this._onRoomMemberMembership);
|
||||
MatrixClientPeg.get().on("RoomMember.membership", this._onRoomMemberMembership);
|
||||
|
||||
this.props.matrixClient.getRoomDirectoryVisibility(
|
||||
MatrixClientPeg.get().getRoomDirectoryVisibility(
|
||||
this.props.room.roomId
|
||||
).done((result) => {
|
||||
this.setState({ isRoomPublished: result.visibility === "public" });
|
||||
|
@ -153,7 +147,7 @@ module.exports = WithMatrixClient(React.createClass({
|
|||
componentWillUnmount: function() {
|
||||
ScalarMessaging.stopListening();
|
||||
|
||||
this.props.matrixClient.removeListener("RoomMember.membership", this._onRoomMemberMembership);
|
||||
MatrixClientPeg.get().removeListener("RoomMember.membership", this._onRoomMemberMembership);
|
||||
|
||||
dis.dispatch({
|
||||
action: 'ui_opacity',
|
||||
|
@ -201,14 +195,14 @@ module.exports = WithMatrixClient(React.createClass({
|
|||
|
||||
// name and topic
|
||||
if (this._hasDiff(this.state.name, originalState.name)) {
|
||||
promises.push(this.props.matrixClient.setRoomName(roomId, this.state.name));
|
||||
promises.push(MatrixClientPeg.get().setRoomName(roomId, this.state.name));
|
||||
}
|
||||
if (this._hasDiff(this.state.topic, originalState.topic)) {
|
||||
promises.push(this.props.matrixClient.setRoomTopic(roomId, this.state.topic));
|
||||
promises.push(MatrixClientPeg.get().setRoomTopic(roomId, this.state.topic));
|
||||
}
|
||||
|
||||
if (this.state.history_visibility !== originalState.history_visibility) {
|
||||
promises.push(this.props.matrixClient.sendStateEvent(
|
||||
promises.push(MatrixClientPeg.get().sendStateEvent(
|
||||
roomId, "m.room.history_visibility",
|
||||
{ history_visibility: this.state.history_visibility },
|
||||
""
|
||||
|
@ -216,14 +210,14 @@ module.exports = WithMatrixClient(React.createClass({
|
|||
}
|
||||
|
||||
if (this.state.isRoomPublished !== originalState.isRoomPublished) {
|
||||
promises.push(this.props.matrixClient.setRoomDirectoryVisibility(
|
||||
promises.push(MatrixClientPeg.get().setRoomDirectoryVisibility(
|
||||
roomId,
|
||||
this.state.isRoomPublished ? "public" : "private"
|
||||
));
|
||||
}
|
||||
|
||||
if (this.state.join_rule !== originalState.join_rule) {
|
||||
promises.push(this.props.matrixClient.sendStateEvent(
|
||||
promises.push(MatrixClientPeg.get().sendStateEvent(
|
||||
roomId, "m.room.join_rules",
|
||||
{ join_rule: this.state.join_rule },
|
||||
""
|
||||
|
@ -231,7 +225,7 @@ module.exports = WithMatrixClient(React.createClass({
|
|||
}
|
||||
|
||||
if (this.state.guest_access !== originalState.guest_access) {
|
||||
promises.push(this.props.matrixClient.sendStateEvent(
|
||||
promises.push(MatrixClientPeg.get().sendStateEvent(
|
||||
roomId, "m.room.guest_access",
|
||||
{ guest_access: this.state.guest_access },
|
||||
""
|
||||
|
@ -242,7 +236,7 @@ module.exports = WithMatrixClient(React.createClass({
|
|||
// power levels
|
||||
var powerLevels = this._getPowerLevels();
|
||||
if (powerLevels) {
|
||||
promises.push(this.props.matrixClient.sendStateEvent(
|
||||
promises.push(MatrixClientPeg.get().sendStateEvent(
|
||||
roomId, "m.room.power_levels", powerLevels, ""
|
||||
));
|
||||
}
|
||||
|
@ -255,12 +249,12 @@ module.exports = WithMatrixClient(React.createClass({
|
|||
switch (diff.place) {
|
||||
case "add":
|
||||
promises.push(
|
||||
this.props.matrixClient.setRoomTag(roomId, diff.key, {})
|
||||
MatrixClientPeg.get().setRoomTag(roomId, diff.key, {})
|
||||
);
|
||||
break;
|
||||
case "del":
|
||||
promises.push(
|
||||
this.props.matrixClient.deleteRoomTag(roomId, diff.key)
|
||||
MatrixClientPeg.get().deleteRoomTag(roomId, diff.key)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
|
@ -317,7 +311,7 @@ module.exports = WithMatrixClient(React.createClass({
|
|||
if (!encrypt) { return q(); }
|
||||
|
||||
var roomId = this.props.room.roomId;
|
||||
return this.props.matrixClient.sendStateEvent(
|
||||
return MatrixClientPeg.get().sendStateEvent(
|
||||
roomId, "m.room.encryption",
|
||||
{ algorithm: "m.megolm.v1.aes-sha2" }
|
||||
);
|
||||
|
@ -482,7 +476,7 @@ module.exports = WithMatrixClient(React.createClass({
|
|||
},
|
||||
|
||||
mayChangeRoomAccess: function() {
|
||||
var cli = this.props.matrixClient;
|
||||
var cli = MatrixClientPeg.get();
|
||||
var roomState = this.props.room.currentState;
|
||||
return (roomState.mayClientSendStateEvent("m.room.join_rules", cli) &&
|
||||
roomState.mayClientSendStateEvent("m.room.guest_access", cli));
|
||||
|
@ -519,7 +513,7 @@ module.exports = WithMatrixClient(React.createClass({
|
|||
|
||||
onForgetClick() {
|
||||
// FIXME: duplicated with RoomTagContextualMenu (and dead code in RoomView)
|
||||
this.props.matrixClient.forget(this.props.room.roomId).done(function() {
|
||||
MatrixClientPeg.get().forget(this.props.room.roomId).done(function() {
|
||||
dis.dispatch({ action: 'view_next_room' });
|
||||
}, function(err) {
|
||||
var errCode = err.errcode || "unknown error code";
|
||||
|
@ -560,7 +554,7 @@ module.exports = WithMatrixClient(React.createClass({
|
|||
},
|
||||
|
||||
_renderEncryptionSection: function() {
|
||||
var cli = this.props.matrixClient;
|
||||
var cli = MatrixClientPeg.get();
|
||||
var roomState = this.props.room.currentState;
|
||||
var isEncrypted = cli.isRoomEncrypted(this.props.room.roomId);
|
||||
var isGlobalBlacklistUnverified = UserSettingsStore.getLocalSettings().blacklistUnverifiedDevices;
|
||||
|
@ -614,7 +608,7 @@ module.exports = WithMatrixClient(React.createClass({
|
|||
var PowerSelector = sdk.getComponent('elements.PowerSelector');
|
||||
var Loader = sdk.getComponent("elements.Spinner");
|
||||
|
||||
var cli = this.props.matrixClient;
|
||||
var cli = MatrixClientPeg.get();
|
||||
var roomState = this.props.room.currentState;
|
||||
var user_id = cli.credentials.userId;
|
||||
|
||||
|
@ -839,7 +833,7 @@ module.exports = WithMatrixClient(React.createClass({
|
|||
<input type="checkbox" disabled={ !roomState.mayClientSendStateEvent("m.room.aliases", cli) }
|
||||
onChange={ this._onToggle.bind(this, "isRoomPublished", true, false)}
|
||||
checked={this.state.isRoomPublished}/>
|
||||
List this room in { this.props.matrixClient.getDomain() }'s room directory?
|
||||
List this room in { MatrixClientPeg.get().getDomain() }'s room directory?
|
||||
</label>
|
||||
</div>
|
||||
<div className="mx_RoomSettings_settings">
|
||||
|
@ -949,4 +943,4 @@ module.exports = WithMatrixClient(React.createClass({
|
|||
</div>
|
||||
);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue