mirror of https://github.com/vector-im/riot-web
remove create_room for now. lots of stupid bugfixes across the board.
parent
82a159d651
commit
5b5bd9aef1
|
@ -64,7 +64,7 @@ module.exports = React.createClass({
|
||||||
collapse_lhs: false,
|
collapse_lhs: false,
|
||||||
collapse_rhs: false,
|
collapse_rhs: false,
|
||||||
ready: false,
|
ready: false,
|
||||||
width: 10000
|
width: 10000,
|
||||||
};
|
};
|
||||||
if (s.logged_in) {
|
if (s.logged_in) {
|
||||||
if (MatrixClientPeg.get().getRooms().length) {
|
if (MatrixClientPeg.get().getRooms().length) {
|
||||||
|
@ -304,7 +304,7 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'view_room':
|
case 'view_room':
|
||||||
this._viewRoom(payload.room_id);
|
this._viewRoom(payload.room_id, payload.show_settings);
|
||||||
break;
|
break;
|
||||||
case 'view_prev_room':
|
case 'view_prev_room':
|
||||||
roomIndexDelta = -1;
|
roomIndexDelta = -1;
|
||||||
|
@ -357,8 +357,29 @@ module.exports = React.createClass({
|
||||||
this.notifyNewScreen('settings');
|
this.notifyNewScreen('settings');
|
||||||
break;
|
break;
|
||||||
case 'view_create_room':
|
case 'view_create_room':
|
||||||
this._setPage(this.PageTypes.CreateRoom);
|
//this._setPage(this.PageTypes.CreateRoom);
|
||||||
this.notifyNewScreen('new');
|
//this.notifyNewScreen('new');
|
||||||
|
|
||||||
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
|
var Loader = sdk.getComponent("elements.Spinner");
|
||||||
|
var modal = Modal.createDialog(Loader);
|
||||||
|
|
||||||
|
MatrixClientPeg.get().createRoom({
|
||||||
|
preset: "private_chat"
|
||||||
|
}).done(function(res) {
|
||||||
|
modal.close();
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'view_room',
|
||||||
|
room_id: res.room_id,
|
||||||
|
show_settings: true,
|
||||||
|
});
|
||||||
|
}, function(err) {
|
||||||
|
modal.close();
|
||||||
|
Modal.createDialog(ErrorDialog, {
|
||||||
|
title: "Failed to create room",
|
||||||
|
description: err.toString()
|
||||||
|
});
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case 'view_room_directory':
|
case 'view_room_directory':
|
||||||
this._setPage(this.PageTypes.RoomDirectory);
|
this._setPage(this.PageTypes.RoomDirectory);
|
||||||
|
@ -399,7 +420,7 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_viewRoom: function(roomId) {
|
_viewRoom: function(roomId, showSettings) {
|
||||||
// before we switch room, record the scroll state of the current room
|
// before we switch room, record the scroll state of the current room
|
||||||
this._updateScrollMap();
|
this._updateScrollMap();
|
||||||
|
|
||||||
|
@ -437,6 +458,9 @@ module.exports = React.createClass({
|
||||||
var scrollState = this.scrollStateMap[roomId];
|
var scrollState = this.scrollStateMap[roomId];
|
||||||
this.refs.roomView.restoreScrollState(scrollState);
|
this.refs.roomView.restoreScrollState(scrollState);
|
||||||
}
|
}
|
||||||
|
if (this.refs.roomView && showSettings) {
|
||||||
|
this.refs.roomView.showSettings(true);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// update scrollStateMap according to the current scroll state of the
|
// update scrollStateMap according to the current scroll state of the
|
||||||
|
|
|
@ -79,7 +79,7 @@ module.exports = React.createClass({
|
||||||
hasUnsentMessages: this._hasUnsentMessages(room),
|
hasUnsentMessages: this._hasUnsentMessages(room),
|
||||||
callState: null,
|
callState: null,
|
||||||
guestsCanJoin: false,
|
guestsCanJoin: false,
|
||||||
readMarkerEventId: room.getEventReadUpTo(MatrixClientPeg.get().credentials.userId),
|
readMarkerEventId: room ? room.getEventReadUpTo(MatrixClientPeg.get().credentials.userId) : undefined,
|
||||||
readMarkerGhostEventId: undefined
|
readMarkerGhostEventId: undefined
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -894,7 +894,7 @@ module.exports = React.createClass({
|
||||||
old_guest_join = (old_guest_join.getContent().guest_access === "can_join");
|
old_guest_join = (old_guest_join.getContent().guest_access === "can_join");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
old_guest_join = (old_guest_join.getContent().guest_access === "forbidden");
|
old_guest_join = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var old_canonical_alias = this.state.room.currentState.getStateEvents('m.room.canonical_alias', '');
|
var old_canonical_alias = this.state.room.currentState.getStateEvents('m.room.canonical_alias', '');
|
||||||
|
@ -1337,6 +1337,13 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showSettings: function(show) {
|
||||||
|
// XXX: this is a bit naughty; we should be doing this via props
|
||||||
|
if (show) {
|
||||||
|
this.setState({editingRoomSettings: true});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var RoomHeader = sdk.getComponent('rooms.RoomHeader');
|
var RoomHeader = sdk.getComponent('rooms.RoomHeader');
|
||||||
var MessageComposer = sdk.getComponent('rooms.MessageComposer');
|
var MessageComposer = sdk.getComponent('rooms.MessageComposer');
|
||||||
|
@ -1487,7 +1494,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
var aux = null;
|
var aux = null;
|
||||||
if (this.state.editingRoomSettings) {
|
if (this.state.editingRoomSettings) {
|
||||||
aux = <RoomSettings ref="room_settings" onSaveClick={this.onSaveClick} room={this.state.room} />;
|
aux = <RoomSettings ref="room_settings" onSaveClick={this.onSaveClick} onCancelClick={this.onCancelClick} room={this.state.room} />;
|
||||||
}
|
}
|
||||||
else if (this.state.uploadingRoomSettings) {
|
else if (this.state.uploadingRoomSettings) {
|
||||||
var Loader = sdk.getComponent("elements.Spinner");
|
var Loader = sdk.getComponent("elements.Spinner");
|
||||||
|
|
|
@ -61,7 +61,12 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillReceiveProps: function(nextProps) {
|
componentWillReceiveProps: function(nextProps) {
|
||||||
this.value = nextProps.initialValue;
|
if (nextProps.initialValue !== this.props.initialValue) {
|
||||||
|
this.value = nextProps.initialValue;
|
||||||
|
if (this.refs.editable_div) {
|
||||||
|
this.showPlaceholder(!this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
|
@ -71,11 +76,7 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidUpdate: function(newProps) {
|
componentDidUpdate: function() {
|
||||||
this.value = this.props.initialValue;
|
|
||||||
if (this.refs.editable_div) {
|
|
||||||
this.showPlaceholder(!this.value);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
showPlaceholder: function(show) {
|
showPlaceholder: function(show) {
|
||||||
|
|
|
@ -281,7 +281,7 @@ module.exports = React.createClass({
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<form onSubmit={this.onPopulateInvite}>
|
<form onSubmit={this.onPopulateInvite}>
|
||||||
<input className="mx_MemberList_invite" ref="invite" placeholder="Invite user (email)"/>
|
<input className="mx_MemberList_invite" ref="invite" id="mx_MemberList_invite" placeholder="Invite user (email)"/>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
// 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, and factored out with RoomSettings
|
||||||
var power_levels = this.props.room.currentState.getStateEvents('m.room.power_levels', '');
|
var power_levels = this.props.room.currentState.getStateEvents('m.room.power_levels', '');
|
||||||
var events_levels = power_levels.events || {};
|
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) {
|
if (power_levels) {
|
||||||
|
@ -169,20 +169,21 @@ module.exports = React.createClass({
|
||||||
var user_levels = [];
|
var user_levels = [];
|
||||||
var current_user_level = 0;
|
var current_user_level = 0;
|
||||||
}
|
}
|
||||||
|
var state_default = parseInt((power_levels ? power_levels.state_default : 0) || 0);
|
||||||
|
|
||||||
var room_avatar_level = parseInt(power_levels.state_default || 0);
|
var room_avatar_level = state_default;
|
||||||
if (events_levels['m.room.avatar'] !== undefined) {
|
if (events_levels['m.room.avatar'] !== undefined) {
|
||||||
room_avatar_level = events_levels['m.room.avatar'];
|
room_avatar_level = events_levels['m.room.avatar'];
|
||||||
}
|
}
|
||||||
var can_set_room_avatar = current_user_level >= room_avatar_level;
|
var can_set_room_avatar = current_user_level >= room_avatar_level;
|
||||||
|
|
||||||
var room_name_level = parseInt(power_levels.state_default || 0);
|
var room_name_level = state_default;
|
||||||
if (events_levels['m.room.name'] !== undefined) {
|
if (events_levels['m.room.name'] !== undefined) {
|
||||||
room_name_level = events_levels['m.room.name'];
|
room_name_level = events_levels['m.room.name'];
|
||||||
}
|
}
|
||||||
var can_set_room_name = current_user_level >= room_name_level;
|
var can_set_room_name = current_user_level >= room_name_level;
|
||||||
|
|
||||||
var room_topic_level = parseInt(power_levels.state_default || 0);
|
var room_topic_level = state_default;
|
||||||
if (events_levels['m.room.topic'] !== undefined) {
|
if (events_levels['m.room.topic'] !== undefined) {
|
||||||
room_topic_level = events_levels['m.room.topic'];
|
room_topic_level = events_levels['m.room.topic'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,16 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
room: React.PropTypes.object.isRequired,
|
room: React.PropTypes.object.isRequired,
|
||||||
|
onSaveClick: React.PropTypes.func,
|
||||||
|
onCancelClick: React.PropTypes.func,
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
|
// XXX: dirty hack to gutwrench to focus on the invite box
|
||||||
|
if (this.props.room.getJoinedMembers().length == 1) {
|
||||||
|
var inviteBox = document.getElementById("mx_MemberList_invite");
|
||||||
|
if (inviteBox) setTimeout(function() { inviteBox.focus(); }, 0);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
|
@ -310,7 +317,7 @@ module.exports = React.createClass({
|
||||||
guest_access = guest_access.getContent().guest_access;
|
guest_access = guest_access.getContent().guest_access;
|
||||||
}
|
}
|
||||||
|
|
||||||
var events_levels = power_levels.events || {};
|
var events_levels = (power_levels ? power_levels.events : {}) || {};
|
||||||
|
|
||||||
var user_id = MatrixClientPeg.get().credentials.userId;
|
var user_id = MatrixClientPeg.get().credentials.userId;
|
||||||
|
|
||||||
|
@ -359,13 +366,15 @@ module.exports = React.createClass({
|
||||||
var can_change_levels = false;
|
var can_change_levels = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var room_aliases_level = parseInt(power_levels.state_default || 0);
|
var state_default = (parseInt(power_levels ? power_levels.state_default : 0) || 0);
|
||||||
|
|
||||||
|
var room_aliases_level = state_default;
|
||||||
if (events_levels['m.room.aliases'] !== undefined) {
|
if (events_levels['m.room.aliases'] !== undefined) {
|
||||||
room_avatar_level = events_levels['m.room.aliases'];
|
room_avatar_level = events_levels['m.room.aliases'];
|
||||||
}
|
}
|
||||||
var can_set_room_aliases = current_user_level >= room_aliases_level;
|
var can_set_room_aliases = current_user_level >= room_aliases_level;
|
||||||
|
|
||||||
var canonical_alias_level = parseInt(power_levels.state_default || 0);
|
var canonical_alias_level = state_default;
|
||||||
if (events_levels['m.room.canonical_alias'] !== undefined) {
|
if (events_levels['m.room.canonical_alias'] !== undefined) {
|
||||||
room_avatar_level = events_levels['m.room.canonical_alias'];
|
room_avatar_level = events_levels['m.room.canonical_alias'];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue