mirror of https://github.com/vector-im/riot-web
Merge pull request #134 from matrix-org/dbkr/fix_preview_bar
Put the room preview bar back for rooms that aren't peekablepull/21833/head
commit
d0c8dadaf6
|
@ -122,6 +122,7 @@ module.exports = React.createClass({
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
this.last_rr_sent_event_id = undefined;
|
this.last_rr_sent_event_id = undefined;
|
||||||
this.dispatcherRef = dis.register(this.onAction);
|
this.dispatcherRef = dis.register(this.onAction);
|
||||||
|
MatrixClientPeg.get().on("Room", this.onRoom);
|
||||||
MatrixClientPeg.get().on("Room.timeline", this.onRoomTimeline);
|
MatrixClientPeg.get().on("Room.timeline", this.onRoomTimeline);
|
||||||
MatrixClientPeg.get().on("Room.name", this.onRoomName);
|
MatrixClientPeg.get().on("Room.name", this.onRoomName);
|
||||||
MatrixClientPeg.get().on("Room.accountData", this.onRoomAccountData);
|
MatrixClientPeg.get().on("Room.accountData", this.onRoomAccountData);
|
||||||
|
@ -163,10 +164,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
console.log("Attempting to peek into room %s", this.props.roomId);
|
console.log("Attempting to peek into room %s", this.props.roomId);
|
||||||
|
|
||||||
roomProm = MatrixClientPeg.get().peekInRoom(this.props.roomId).catch((err) => {
|
roomProm = MatrixClientPeg.get().peekInRoom(this.props.roomId).then((room) => {
|
||||||
console.error("Failed to peek into room: %s", err);
|
|
||||||
throw err;
|
|
||||||
}).then((room) => {
|
|
||||||
this.setState({
|
this.setState({
|
||||||
room: room
|
room: room
|
||||||
});
|
});
|
||||||
|
@ -180,6 +178,18 @@ module.exports = React.createClass({
|
||||||
roomProm.then((room) => {
|
roomProm.then((room) => {
|
||||||
this._calculatePeekRules(room);
|
this._calculatePeekRules(room);
|
||||||
return this._initTimeline(this.props);
|
return this._initTimeline(this.props);
|
||||||
|
}).catch((err) => {
|
||||||
|
// This won't necessarily be a MatrixError, but we duck-type
|
||||||
|
// here and say if it's got an 'errcode' key with the right value,
|
||||||
|
// it means we can't peek.
|
||||||
|
if (err.errcode == "M_GUEST_ACCESS_FORBIDDEN") {
|
||||||
|
// This is fine: the room just isn't peekable (we assume).
|
||||||
|
this.setState({
|
||||||
|
timelineLoading: false,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}).done();
|
}).done();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -266,6 +276,7 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
dis.unregister(this.dispatcherRef);
|
dis.unregister(this.dispatcherRef);
|
||||||
if (MatrixClientPeg.get()) {
|
if (MatrixClientPeg.get()) {
|
||||||
|
MatrixClientPeg.get().removeListener("Room", this.onRoom);
|
||||||
MatrixClientPeg.get().removeListener("Room.timeline", this.onRoomTimeline);
|
MatrixClientPeg.get().removeListener("Room.timeline", this.onRoomTimeline);
|
||||||
MatrixClientPeg.get().removeListener("Room.name", this.onRoomName);
|
MatrixClientPeg.get().removeListener("Room.name", this.onRoomName);
|
||||||
MatrixClientPeg.get().removeListener("Room.accountData", this.onRoomAccountData);
|
MatrixClientPeg.get().removeListener("Room.accountData", this.onRoomAccountData);
|
||||||
|
@ -411,6 +422,20 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onRoom: function(room) {
|
||||||
|
// This event is fired when the room is 'stored' by the JS SDK, which
|
||||||
|
// means it's now a fully-fledged room object ready to be used, so
|
||||||
|
// set it in our state and start using it (ie. init the timeline)
|
||||||
|
// This will happen if we start off viewing a room we're not joined,
|
||||||
|
// then join it whilst RoomView is looking at that room.
|
||||||
|
if (room.roomId == this.props.roomId) {
|
||||||
|
this.setState({
|
||||||
|
room: room
|
||||||
|
});
|
||||||
|
this._initTimeline(this.props).done();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onRoomName: function(room) {
|
onRoomName: function(room) {
|
||||||
if (room.roomId == this.props.roomId) {
|
if (room.roomId == this.props.roomId) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -687,6 +712,10 @@ module.exports = React.createClass({
|
||||||
// NOT when it comes down /sync. If there is no room, we'll keep the
|
// 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
|
// 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.
|
// "join" we'll keep this flag set until it comes down /sync.
|
||||||
|
|
||||||
|
// We'll need to initialise the timeline when joining, but due to
|
||||||
|
// the above, we can't do it here: we do it in onRoom instead,
|
||||||
|
// once we have a useable room object.
|
||||||
var room = MatrixClientPeg.get().getRoom(self.props.roomId);
|
var room = MatrixClientPeg.get().getRoom(self.props.roomId);
|
||||||
var me = MatrixClientPeg.get().credentials.userId;
|
var me = MatrixClientPeg.get().credentials.userId;
|
||||||
self.setState({
|
self.setState({
|
||||||
|
|
Loading…
Reference in New Issue