@@ -126,38 +126,47 @@ module.exports = React.createClass({
126
126
} ) ;
127
127
} ,
128
128
129
- showRoom : function ( room , ev ) {
129
+ onRoomClicked : function ( room , ev ) {
130
130
if ( ev . shiftKey ) {
131
131
ev . preventDefault ( ) ;
132
132
this . removeFromDirectory ( room ) ;
133
- return ;
133
+ } else {
134
+ this . showRoom ( room ) ;
134
135
}
136
+ } ,
135
137
136
- var oob_data = { } ;
137
- if ( MatrixClientPeg . get ( ) . isGuest ( ) ) {
138
- if ( ! room . world_readable && ! room . guest_can_join ) {
139
- var NeedToRegisterDialog = sdk . getComponent ( "dialogs.NeedToRegisterDialog" ) ;
140
- Modal . createDialog ( NeedToRegisterDialog , {
141
- title : "Failed to join the room" ,
142
- description : "This room is inaccessible to guests. You may be able to join if you register."
143
- } ) ;
144
- return ;
145
- }
146
- }
138
+ showRoomAlias : function ( alias ) {
139
+ this . showRoom ( null , alias ) ;
140
+ } ,
147
141
148
- var room_alias = get_display_alias_for_room ( room ) ;
142
+ showRoom : function ( room , room_alias ) {
143
+ var payload = { action : 'view_room' } ;
144
+ if ( room ) {
145
+ // Don't let the user view a room they won't be able to either
146
+ // peek or join: fail earlier so they don't have to click back
147
+ // to the directory.
148
+ if ( MatrixClientPeg . get ( ) . isGuest ( ) ) {
149
+ if ( ! room . world_readable && ! room . guest_can_join ) {
150
+ var NeedToRegisterDialog = sdk . getComponent ( "dialogs.NeedToRegisterDialog" ) ;
151
+ Modal . createDialog ( NeedToRegisterDialog , {
152
+ title : "Failed to join the room" ,
153
+ description : "This room is inaccessible to guests. You may be able to join if you register."
154
+ } ) ;
155
+ return ;
156
+ }
157
+ }
149
158
150
- oob_data = {
151
- avatarUrl : room . avatar_url ,
152
- // XXX: This logic is duplicated from the JS SDK which
153
- // would normally decide what the name is.
154
- name : room . name || room_alias || "Unnamed room" ,
155
- } ;
159
+ if ( ! room_alias ) {
160
+ room_alias = get_display_alias_for_room ( room ) ;
161
+ }
156
162
157
- var payload = {
158
- oob_data : oob_data ,
159
- action : 'view_room' ,
160
- } ;
163
+ payload . oob_data = {
164
+ avatarUrl : room . avatar_url ,
165
+ // XXX: This logic is duplicated from the JS SDK which
166
+ // would normally decide what the name is.
167
+ name : room . name || room_alias || "Unnamed room" ,
168
+ } ;
169
+ }
161
170
// It's not really possible to join Matrix rooms by ID because the HS has no way to know
162
171
// which servers to start querying. However, there's no other way to join rooms in
163
172
// this list without aliases at present, so if roomAlias isn't set here we have no
@@ -213,7 +222,7 @@ module.exports = React.createClass({
213
222
214
223
rows . unshift (
215
224
< tr key = { rooms [ i ] . room_id }
216
- onClick = { self . showRoom . bind ( null , rooms [ i ] ) }
225
+ onClick = { self . onRoomClicked . bind ( self , rooms [ i ] ) }
217
226
// cancel onMouseDown otherwise shift-clicking highlights text
218
227
onMouseDown = { ( ev ) => { ev . preventDefault ( ) ; } }
219
228
>
@@ -245,7 +254,7 @@ module.exports = React.createClass({
245
254
this . forceUpdate ( ) ;
246
255
this . setState ( { roomAlias : this . refs . roomAlias . value } )
247
256
if ( ev . key == "Enter" ) {
248
- this . showRoom ( null , this . refs . roomAlias . value ) ;
257
+ this . showRoomAlias ( this . refs . roomAlias . value ) ;
249
258
}
250
259
} ,
251
260
0 commit comments