make /user URLs work

pull/2056/head
Matthew Hodgson 2016-08-28 14:04:25 +01:00
parent 9b8e127e23
commit 36a608952d
1 changed files with 22 additions and 12 deletions

View File

@ -17,7 +17,8 @@ limitations under the License.
'use strict'; 'use strict';
var React = require('react'); var React = require('react');
var sdk = require('matrix-react-sdk') var sdk = require('matrix-react-sdk');
var Matrix = require("matrix-js-sdk");
var dis = require('matrix-react-sdk/lib/dispatcher'); var dis = require('matrix-react-sdk/lib/dispatcher');
var MatrixClientPeg = require("matrix-react-sdk/lib/MatrixClientPeg"); var MatrixClientPeg = require("matrix-react-sdk/lib/MatrixClientPeg");
var rate_limited_func = require('matrix-react-sdk/lib/ratelimitedfunc'); var rate_limited_func = require('matrix-react-sdk/lib/ratelimitedfunc');
@ -45,9 +46,18 @@ module.exports = React.createClass({
}, },
getInitialState: function() { getInitialState: function() {
if (this.props.userId) {
var member = new Matrix.RoomMember(null, this.props.userId);
return {
phase: this.Phase.MemberInfo,
member: member,
}
}
else {
return { return {
phase: this.Phase.MemberList phase: this.Phase.MemberList
} }
}
}, },
onMemberListButtonClick: function() { onMemberListButtonClick: function() {
@ -97,7 +107,7 @@ module.exports = React.createClass({
}); });
} }
} }
if (payload.action === "view_room") { else if (payload.action === "view_room") {
if (this.state.phase === this.Phase.MemberInfo) { if (this.state.phase === this.Phase.MemberInfo) {
this.setState({ this.setState({
phase: this.Phase.MemberList phase: this.Phase.MemberList
@ -145,15 +155,15 @@ module.exports = React.createClass({
{ filesHighlight } { filesHighlight }
</div> </div>
</div>; </div>;
}
if (!this.props.collapsed) { if (!this.props.collapsed) {
if(this.state.phase == this.Phase.MemberList) { if(this.props.roomId && this.state.phase == this.Phase.MemberList) {
panel = <MemberList roomId={this.props.roomId} key={this.props.roomId} /> panel = <MemberList roomId={this.props.roomId} key={this.props.roomId} />
} }
else if(this.state.phase == this.Phase.MemberInfo) { else if(this.state.phase == this.Phase.MemberInfo) {
var MemberInfo = sdk.getComponent('rooms.MemberInfo'); var MemberInfo = sdk.getComponent('rooms.MemberInfo');
panel = <MemberInfo roomId={this.props.roomId} member={this.state.member} key={this.props.roomId} /> panel = <MemberInfo member={this.state.member} key={this.props.roomId || this.props.userId} />
}
} }
} }