Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit c32b717

Browse files
authored
Merge pull request #1099 from matrix-org/luke/fix-spinner-until-room-available
Display a spinner until new room object after join success
2 parents a05bafe + cc46fd3 commit c32b717

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

src/components/structures/RoomView.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ module.exports = React.createClass({
179179
'joining?', newState.joining,
180180
);
181181

182+
// finished joining, start waiting for a room and show a spinner. See onRoom.
183+
newState.waitingForRoom = this.state.joining && !newState.joining &&
184+
!RoomViewStore.getJoinError();
185+
182186
// NB: This does assume that the roomID will not change for the lifetime of
183187
// the RoomView instance
184188
if (initial) {
@@ -218,23 +222,19 @@ module.exports = React.createClass({
218222
// which must be by alias or invite wherever possible (peeking currently does
219223
// not work over federation).
220224

221-
// NB. We peek if we are not in the room, although if we try to peek into
222-
// a room in which we have a member event (ie. we've left) synapse will just
223-
// send us the same data as we get in the sync (ie. the last events we saw).
225+
// NB. We peek if we have never seen the room before (i.e. js-sdk does not know
226+
// about it). We don't peek in the historical case where we were joined but are
227+
// now not joined because the js-sdk peeking API will clobber our historical room,
228+
// making it impossible to indicate a newly joined room.
224229
const room = this.state.room;
225-
let isUserJoined = null;
226230
if (room) {
227-
isUserJoined = room.hasMembershipState(
228-
MatrixClientPeg.get().credentials.userId, 'join',
229-
);
230-
231231
this._updateAutoComplete(room);
232232
this.tabComplete.loadEntries(room);
233233
}
234-
if (!isUserJoined && !this.state.joining && this.state.roomId) {
234+
if (!this.state.joining && this.state.roomId) {
235235
if (this.props.autoJoin) {
236236
this.onJoinButtonClicked();
237-
} else if (this.state.roomId) {
237+
} else if (!room) {
238238
console.log("Attempting to peek into room %s", this.state.roomId);
239239
this.setState({
240240
peekLoading: true,
@@ -259,7 +259,8 @@ module.exports = React.createClass({
259259
}
260260
}).done();
261261
}
262-
} else if (isUserJoined) {
262+
} else if (room) {
263+
// Stop peeking because we have joined this room previously
263264
MatrixClientPeg.get().stopPeeking();
264265
this.setState({
265266
unsentMessageError: this._getUnsentMessageError(room),
@@ -622,6 +623,7 @@ module.exports = React.createClass({
622623
}
623624
this.setState({
624625
room: room,
626+
waitingForRoom: false,
625627
}, () => {
626628
this._onRoomLoaded(room);
627629
});
@@ -677,7 +679,14 @@ module.exports = React.createClass({
677679

678680
onRoomMemberMembership: function(ev, member, oldMembership) {
679681
if (member.userId == MatrixClientPeg.get().credentials.userId) {
680-
this.forceUpdate();
682+
683+
if (member.membership === 'join') {
684+
this.setState({
685+
waitingForRoom: false,
686+
});
687+
} else {
688+
this.forceUpdate();
689+
}
681690
}
682691
},
683692

@@ -1464,7 +1473,7 @@ module.exports = React.createClass({
14641473
onRejectClick={ this.onRejectThreepidInviteButtonClicked }
14651474
canPreview={ false } error={ this.state.roomLoadError }
14661475
roomAlias={room_alias}
1467-
spinner={this.state.joining}
1476+
spinner={this.state.joining || this.state.waitingForRoom}
14681477
inviterName={inviterName}
14691478
invitedEmail={invitedEmail}
14701479
room={this.state.room}
@@ -1583,7 +1592,7 @@ module.exports = React.createClass({
15831592
<RoomPreviewBar onJoinClick={this.onJoinButtonClicked}
15841593
onForgetClick={ this.onForgetClick }
15851594
onRejectClick={this.onRejectThreepidInviteButtonClicked}
1586-
spinner={this.state.joining}
1595+
spinner={this.state.joining || this.state.waitingForRoom}
15871596
inviterName={inviterName}
15881597
invitedEmail={invitedEmail}
15891598
canPreview={this.state.canPeek}

0 commit comments

Comments
 (0)