mirror of https://github.com/vector-im/riot-web
switch to using MatrixClientPeg.get().maySendStateEvent() everywhere
parent
8a905dec58
commit
014ea9a328
|
@ -272,7 +272,8 @@ module.exports = React.createClass({
|
|||
|
||||
var power_levels = this.props.room.currentState.getStateEvents('m.room.power_levels', '');
|
||||
var events_levels = (power_levels ? power_levels.events : {}) || {};
|
||||
var user_id = MatrixClientPeg.get().credentials.userId;
|
||||
var cli = MatrixClientPeg.get();
|
||||
var user_id = cli.credentials.userId;
|
||||
|
||||
if (power_levels) {
|
||||
power_levels = power_levels.getContent();
|
||||
|
@ -321,18 +322,7 @@ module.exports = React.createClass({
|
|||
|
||||
var state_default = (parseInt(power_levels ? power_levels.state_default : 0) || 0);
|
||||
|
||||
var canSetEventType = function(eventType) {
|
||||
if (MatrixClientPeg.get().isGuest()) {
|
||||
return false;
|
||||
}
|
||||
var level = state_default;
|
||||
if (events_levels[eventType] !== undefined) {
|
||||
level = events_levels[eventType];
|
||||
}
|
||||
return current_user_level >= level;
|
||||
}
|
||||
|
||||
var canSetTag = !MatrixClientPeg.get().isGuest();
|
||||
var canSetTag = !cli.isGuest();
|
||||
|
||||
var self = this;
|
||||
|
||||
|
@ -425,19 +415,19 @@ module.exports = React.createClass({
|
|||
|
||||
<div className="mx_RoomSettings_toggles">
|
||||
<label>
|
||||
<input type="checkbox" disabled={ MatrixClientPeg.get().isGuest() }
|
||||
<input type="checkbox" disabled={ cli.isGuest() }
|
||||
onChange={this._onToggle.bind(this, "areNotifsMuted", true, false)}
|
||||
defaultChecked={this.state.areNotifsMuted}/>
|
||||
Mute notifications for this room
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" disabled={ !canSetEventType("m.room.join_rule") }
|
||||
<input type="checkbox" disabled={ !cli.maySendStateEvent("m.room.join_rule") }
|
||||
onChange={this._onToggle.bind(this, "join_rule", "invite", "public")}
|
||||
defaultChecked={this.state.join_rule !== "public"}/>
|
||||
Make this room private
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" disabled={ !canSetEventType("m.room.guest_access") }
|
||||
<input type="checkbox" disabled={ !cli.maySendStateEvent("m.room.guest_access") }
|
||||
onChange={this._onToggle.bind(this, "guest_access", "can_join", "forbidden")}
|
||||
defaultChecked={this.state.guest_access === "can_join"}/>
|
||||
Let guests join this room
|
||||
|
@ -446,28 +436,28 @@ module.exports = React.createClass({
|
|||
<h3>Who can read history?</h3>
|
||||
<label htmlFor="hvis_wr">
|
||||
<input type="radio" id="hvis_wr" name="historyVis" value="world_readable"
|
||||
disabled={ !canSetEventType("m.room.history_visibility") }
|
||||
disabled={ !cli.maySendStateEvent("m.room.history_visibility") }
|
||||
defaultChecked={historyVisibility === "world_readable"}
|
||||
onChange={this._onHistoryRadioToggle} />
|
||||
Anyone
|
||||
</label>
|
||||
<label htmlFor="hvis_sh">
|
||||
<input type="radio" id="hvis_sh" name="historyVis" value="shared"
|
||||
disabled={ !canSetEventType("m.room.history_visibility") }
|
||||
disabled={ !cli.maySendStateEvent("m.room.history_visibility") }
|
||||
defaultChecked={historyVisibility === "shared"}
|
||||
onChange={this._onHistoryRadioToggle} />
|
||||
Members only (since the room began)
|
||||
</label>
|
||||
<label htmlFor="hvis_inv">
|
||||
<input type="radio" id="hvis_inv" name="historyVis" value="invited"
|
||||
disabled={ !canSetEventType("m.room.history_visibility") }
|
||||
disabled={ !cli.maySendStateEvent("m.room.history_visibility") }
|
||||
defaultChecked={historyVisibility === "invited"}
|
||||
onChange={this._onHistoryRadioToggle} />
|
||||
Members only (since they were invited)
|
||||
</label>
|
||||
<label htmlFor="hvis_joi">
|
||||
<input type="radio" id="hvis_joi" name="historyVis" value="joined"
|
||||
disabled={ !canSetEventType("m.room.history_visibility") }
|
||||
disabled={ !cli.maySendStateEvent("m.room.history_visibility") }
|
||||
defaultChecked={historyVisibility === "joined"}
|
||||
onChange={this._onHistoryRadioToggle} />
|
||||
Members only (since they joined)
|
||||
|
@ -487,8 +477,8 @@ module.exports = React.createClass({
|
|||
|
||||
<AliasSettings ref="alias_settings"
|
||||
roomId={this.props.room.roomId}
|
||||
canSetCanonicalAlias={ canSetEventType("m.room.canonical_alias") }
|
||||
canSetAliases={ canSetEventType("m.room.aliases") }
|
||||
canSetCanonicalAlias={ cli.maySendStateEvent("m.room.canonical_alias") }
|
||||
canSetAliases={ cli.maySendStateEvent("m.room.aliases") }
|
||||
canonicalAliasEvent={this.props.room.currentState.getStateEvents('m.room.canonical_alias', '')}
|
||||
aliasEvents={this.props.room.currentState.getStateEvents('m.room.aliases')} />
|
||||
|
||||
|
|
Loading…
Reference in New Issue