@@ -81,20 +81,30 @@ module.exports = React.createClass({
8181 // });
8282 } ,
8383
84- showRoom : function ( roomId ) {
84+ showRoom : function ( roomIdOrAlias ) {
8585 // extract the metadata from the publicRooms structure to pass
8686 // as out-of-band data to view_room, because we get information
8787 // here that we can't get other than by joining the room in some
8888 // cases.
8989 var room ;
90- for ( var i = 0 ; i < this . state . publicRooms . length ; ++ i ) {
91- if ( this . state . publicRooms [ i ] . room_id == roomId ) {
92- room = this . state . publicRooms [ i ] ;
93- break ;
90+ if ( roomIdOrAlias [ 0 ] == '!' ) {
91+ for ( var i = 0 ; i < this . state . publicRooms . length ; ++ i ) {
92+ if ( this . state . publicRooms [ i ] . room_id == roomIdOrAlias ) {
93+ room = this . state . publicRooms [ i ] ;
94+ break ;
95+ }
9496 }
9597 }
9698 var oob_data = { } ;
9799 if ( room ) {
100+ // pluck the alias out of the room data and use it to join the room, as we cannot
101+ // really join rooms by ID (the HS has no way to get candidate servers). However,
102+ // we still have to do this for room in the public room list that don't have an alias
103+ // since this is currently the only choice.
104+ // (Note we don't just pass the room alias to this function: we still want to be able to
105+ // look up the oob data for which we need the room id).
106+ var alias = room . canonical_alias || ( room . aliases ? room . aliases [ 0 ] : undefined ) ;
107+ if ( alias ) roomIdOrAlias = alias ;
98108 if ( MatrixClientPeg . get ( ) . isGuest ( ) ) {
99109 if ( ! room . world_readable && ! room . guest_can_join ) {
100110 var NeedToRegisterDialog = sdk . getComponent ( "dialogs.NeedToRegisterDialog" ) ;
@@ -114,9 +124,12 @@ module.exports = React.createClass({
114124 } ;
115125 }
116126
127+ // XXX: this interface needs to change to officially accept room IDs
128+ // or aliases, rather than it happening to work if you pass an alias
129+ // as room_id
117130 dis . dispatch ( {
118131 action : 'view_room' ,
119- room_id : roomId ,
132+ room_id : roomIdOrAlias ,
120133 oob_data : oob_data ,
121134 } ) ;
122135 } ,
0 commit comments