@@ -179,6 +179,10 @@ module.exports = React.createClass({
179
179
'joining?' , newState . joining ,
180
180
) ;
181
181
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
+
182
186
// NB: This does assume that the roomID will not change for the lifetime of
183
187
// the RoomView instance
184
188
if ( initial ) {
@@ -218,23 +222,19 @@ module.exports = React.createClass({
218
222
// which must be by alias or invite wherever possible (peeking currently does
219
223
// not work over federation).
220
224
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.
224
229
const room = this . state . room ;
225
- let isUserJoined = null ;
226
230
if ( room ) {
227
- isUserJoined = room . hasMembershipState (
228
- MatrixClientPeg . get ( ) . credentials . userId , 'join' ,
229
- ) ;
230
-
231
231
this . _updateAutoComplete ( room ) ;
232
232
this . tabComplete . loadEntries ( room ) ;
233
233
}
234
- if ( ! isUserJoined && ! this . state . joining && this . state . roomId ) {
234
+ if ( ! this . state . joining && this . state . roomId ) {
235
235
if ( this . props . autoJoin ) {
236
236
this . onJoinButtonClicked ( ) ;
237
- } else if ( this . state . roomId ) {
237
+ } else if ( ! room ) {
238
238
console . log ( "Attempting to peek into room %s" , this . state . roomId ) ;
239
239
this . setState ( {
240
240
peekLoading : true ,
@@ -259,7 +259,8 @@ module.exports = React.createClass({
259
259
}
260
260
} ) . done ( ) ;
261
261
}
262
- } else if ( isUserJoined ) {
262
+ } else if ( room ) {
263
+ // Stop peeking because we have joined this room previously
263
264
MatrixClientPeg . get ( ) . stopPeeking ( ) ;
264
265
this . setState ( {
265
266
unsentMessageError : this . _getUnsentMessageError ( room ) ,
@@ -622,6 +623,7 @@ module.exports = React.createClass({
622
623
}
623
624
this . setState ( {
624
625
room : room ,
626
+ waitingForRoom : false ,
625
627
} , ( ) => {
626
628
this . _onRoomLoaded ( room ) ;
627
629
} ) ;
@@ -677,7 +679,14 @@ module.exports = React.createClass({
677
679
678
680
onRoomMemberMembership : function ( ev , member , oldMembership ) {
679
681
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
+ }
681
690
}
682
691
} ,
683
692
@@ -1464,7 +1473,7 @@ module.exports = React.createClass({
1464
1473
onRejectClick = { this . onRejectThreepidInviteButtonClicked }
1465
1474
canPreview = { false } error = { this . state . roomLoadError }
1466
1475
roomAlias = { room_alias }
1467
- spinner = { this . state . joining }
1476
+ spinner = { this . state . joining || this . state . waitingForRoom }
1468
1477
inviterName = { inviterName }
1469
1478
invitedEmail = { invitedEmail }
1470
1479
room = { this . state . room }
@@ -1583,7 +1592,7 @@ module.exports = React.createClass({
1583
1592
< RoomPreviewBar onJoinClick = { this . onJoinButtonClicked }
1584
1593
onForgetClick = { this . onForgetClick }
1585
1594
onRejectClick = { this . onRejectThreepidInviteButtonClicked }
1586
- spinner = { this . state . joining }
1595
+ spinner = { this . state . joining || this . state . waitingForRoom }
1587
1596
inviterName = { inviterName }
1588
1597
invitedEmail = { invitedEmail }
1589
1598
canPreview = { this . state . canPeek }
0 commit comments