Merge branch 'matthew/roompreview' of https://github.com/matrix-org/matrix-react-sdk into matthew/roompreview

This commit is contained in:
Matthew Hodgson 2016-01-20 15:49:02 +00:00
commit 5c105a50e2

View file

@ -118,15 +118,11 @@ module.exports = React.createClass({
if (!this.state.room) { if (!this.state.room) {
if (this.props.autoPeek) { if (this.props.autoPeek) {
console.log("Attempting to peek into room %s", this.props.roomId); console.log("Attempting to peek into room %s", this.props.roomId);
MatrixClientPeg.get().peekInRoom(this.props.roomId).done(() => { MatrixClientPeg.get().peekInRoom(this.props.roomId).catch((err) => {
// we don't need to do anything - JS SDK will emit Room events
// which will update the UI. We *do* however need to know if we
// can join the room so we can fiddle with the UI appropriately.
// ...XXX: or do we? can't we just do them onNewRoom?
}, function(err) {
console.error("Failed to peek into room: %s", err); console.error("Failed to peek into room: %s", err);
}).finally(() => { }).finally(() => {
// we don't need to do anything - JS SDK will emit Room events
// which will update the UI.
this.setState({ this.setState({
autoPeekDone: true autoPeekDone: true
}); });
@ -379,6 +375,14 @@ module.exports = React.createClass({
if (member.roomId === this.props.roomId) { if (member.roomId === this.props.roomId) {
// a member state changed in this room, refresh the tab complete list // a member state changed in this room, refresh the tab complete list
this._updateTabCompleteList(this.state.room); this._updateTabCompleteList(this.state.room);
var room = MatrixClientPeg.get().getRoom(this.props.roomId);
var me = MatrixClientPeg.get().credentials.userId;
if (this.state.joining && room.hasMembershipState(me, "join")) {
this.setState({
joining: false
});
}
} }
if (!this.props.ConferenceHandler) { if (!this.props.ConferenceHandler) {
@ -552,10 +556,17 @@ module.exports = React.createClass({
onJoinButtonClicked: function(ev) { onJoinButtonClicked: function(ev) {
var self = this; var self = this;
MatrixClientPeg.get().joinRoom(this.props.roomId).then(function() { MatrixClientPeg.get().joinRoom(this.props.roomId).done(function() {
// It is possible that there is no Room yet if state hasn't come down
// from /sync - joinRoom will resolve when the HTTP request to join succeeds,
// NOT when it comes down /sync. If there is no room, we'll keep the
// joining flag set until we see it. Likewise, if our state is not
// "join" we'll keep this flag set until it comes down /sync.
var room = MatrixClientPeg.get().getRoom(self.props.roomId);
var me = MatrixClientPeg.get().credentials.userId;
self.setState({ self.setState({
joining: false, joining: room ? !room.hasMembershipState(me, "join") : true,
room: MatrixClientPeg.get().getRoom(self.props.roomId) room: room
}); });
}, function(error) { }, function(error) {
self.setState({ self.setState({