mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-02 16:25:56 +03:00
Remove (broken, as it turns out) permission logic from react sdk and use https://github.com/matrix-org/matrix-js-sdk/pull/94 instead.
This commit is contained in:
parent
05a3dab528
commit
5b505cd32d
1 changed files with 13 additions and 33 deletions
|
@ -136,41 +136,21 @@ module.exports = React.createClass({
|
||||||
var settings_button = null;
|
var settings_button = null;
|
||||||
if (this.props.editing) {
|
if (this.props.editing) {
|
||||||
|
|
||||||
// calculate permissions. XXX: this should be done on mount or something, and factored out with RoomSettings
|
// calculate permissions. XXX: this should be done on mount or something
|
||||||
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 user_id = MatrixClientPeg.get().credentials.userId;
|
||||||
|
|
||||||
if (power_levels) {
|
var can_set_room_name = this.props.room.currentState.maySendStateEvent(
|
||||||
power_levels = power_levels.getContent();
|
'm.room.name', user_id
|
||||||
var default_user_level = parseInt(power_levels.users_default || 0);
|
);
|
||||||
var user_levels = power_levels.users || {};
|
var can_set_room_avatar = this.props.room.currentState.maySendStateEvent(
|
||||||
var current_user_level = user_levels[user_id];
|
'm.room.avatar', user_id
|
||||||
if (current_user_level == undefined) current_user_level = default_user_level;
|
);
|
||||||
} else {
|
var can_set_room_topic = this.props.room.currentState.maySendStateEvent(
|
||||||
var default_user_level = 0;
|
'm.room.topic', user_id
|
||||||
var user_levels = [];
|
);
|
||||||
var current_user_level = 0;
|
var can_set_room_name = this.props.room.currentState.maySendStateEvent(
|
||||||
}
|
'm.room.name', user_id
|
||||||
var state_default = parseInt((power_levels ? power_levels.state_default : 0) || 0);
|
);
|
||||||
|
|
||||||
var room_avatar_level = state_default;
|
|
||||||
if (events_levels['m.room.avatar'] !== undefined) {
|
|
||||||
room_avatar_level = events_levels['m.room.avatar'];
|
|
||||||
}
|
|
||||||
var can_set_room_avatar = current_user_level >= room_avatar_level;
|
|
||||||
|
|
||||||
var room_name_level = state_default;
|
|
||||||
if (events_levels['m.room.name'] !== undefined) {
|
|
||||||
room_name_level = events_levels['m.room.name'];
|
|
||||||
}
|
|
||||||
var can_set_room_name = current_user_level >= room_name_level;
|
|
||||||
|
|
||||||
var room_topic_level = state_default;
|
|
||||||
if (events_levels['m.room.topic'] !== undefined) {
|
|
||||||
room_topic_level = events_levels['m.room.topic'];
|
|
||||||
}
|
|
||||||
var can_set_room_topic = current_user_level >= room_topic_level;
|
|
||||||
|
|
||||||
var placeholderName = "Unnamed Room";
|
var placeholderName = "Unnamed Room";
|
||||||
if (this.state.defaultName && this.state.defaultName !== 'Empty room') {
|
if (this.state.defaultName && this.state.defaultName !== 'Empty room') {
|
||||||
|
|
Loading…
Reference in a new issue