@@ -109,6 +109,11 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
109109 this . forceUpdate ( ) ; // because the layout doesn't trigger a re-render
110110 } ;
111111
112+ private onShowLessClick = ( ) => {
113+ this . props . layout . visibleTiles = this . props . layout . minVisibleTiles ;
114+ this . forceUpdate ( ) ; // because the layout doesn't trigger a re-render
115+ } ;
116+
112117 private onOpenMenuClick = ( ev : InputEvent ) => {
113118 ev . preventDefault ( ) ;
114119 ev . stopPropagation ( ) ;
@@ -303,25 +308,42 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
303308 const visibleTiles = tiles . slice ( 0 , nVisible ) ;
304309
305310 // If we're hiding rooms, show a 'show more' button to the user. This button
306- // floats above the resize handle, if we have one present
307- let showMoreButton = null ;
311+ // floats above the resize handle, if we have one present. If the user has all
312+ // tiles visible, it becomes 'show less'.
313+ let showNButton = null ;
308314 if ( tiles . length > nVisible ) {
309315 // we have a cutoff condition - add the button to show all
310316 const numMissing = tiles . length - visibleTiles . length ;
311317 let showMoreText = (
312- < span className = 'mx_RoomSublist2_showMoreButtonText ' >
318+ < span className = 'mx_RoomSublist2_showNButtonText ' >
313319 { _t ( "Show %(count)s more" , { count : numMissing } ) }
314320 </ span >
315321 ) ;
316322 if ( this . props . isMinimized ) showMoreText = null ;
317- showMoreButton = (
318- < div onClick = { this . onShowAllClick } className = 'mx_RoomSublist2_showMoreButton ' >
319- < span className = 'mx_RoomSublist2_showMoreButtonChevron' >
323+ showNButton = (
324+ < div onClick = { this . onShowAllClick } className = 'mx_RoomSublist2_showNButton ' >
325+ < span className = 'mx_RoomSublist2_showMoreButtonChevron mx_RoomSublist2_showNButtonChevron ' >
320326 { /* set by CSS masking */ }
321327 </ span >
322328 { showMoreText }
323329 </ div >
324330 ) ;
331+ } else if ( tiles . length <= nVisible ) {
332+ // we have all tiles visible - add a button to show less
333+ let showLessText = (
334+ < span className = 'mx_RoomSublist2_showNButtonText' >
335+ { _t ( "Show less" ) }
336+ </ span >
337+ ) ;
338+ if ( this . props . isMinimized ) showLessText = null ;
339+ showNButton = (
340+ < div onClick = { this . onShowLessClick } className = 'mx_RoomSublist2_showNButton' >
341+ < span className = 'mx_RoomSublist2_showLessButtonChevron mx_RoomSublist2_showNButtonChevron' >
342+ { /* set by CSS masking */ }
343+ </ span >
344+ { showLessText }
345+ </ div >
346+ ) ;
325347 }
326348
327349 // Figure out if we need a handle
@@ -345,7 +367,7 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
345367
346368 // The padding is variable though, so figure out what we need padding for.
347369 let padding = 0 ;
348- if ( showMoreButton ) padding += showMoreHeight ;
370+ if ( showNButton ) padding += showMoreHeight ;
349371 if ( handles . length > 0 ) padding += resizeHandleHeight ;
350372
351373 const minTilesPx = layout . calculateTilesToPixelsMin ( tiles . length , layout . minVisibleTiles , padding ) ;
@@ -365,7 +387,7 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
365387 className = "mx_RoomSublist2_resizeBox"
366388 >
367389 { visibleTiles }
368- { showMoreButton }
390+ { showNButton }
369391 </ ResizableBox >
370392 )
371393 }
0 commit comments