@@ -52,6 +52,18 @@ module.exports = React.createClass({
5252 } ,
5353
5454 componentDidMount : function ( ) {
55+ this . getPublicRooms ( ) ;
56+ } ,
57+
58+ componentWillUnmount : function ( ) {
59+ // dis.dispatch({
60+ // action: 'ui_opacity',
61+ // sideOpacity: 1.0,
62+ // middleOpacity: 1.0,
63+ // });
64+ } ,
65+
66+ getPublicRooms : function ( ) {
5567 var self = this ;
5668 MatrixClientPeg . get ( ) . publicRooms ( function ( err , data ) {
5769 if ( err ) {
@@ -68,20 +80,43 @@ module.exports = React.createClass({
6880 publicRooms : data . chunk ,
6981 loading : false ,
7082 } ) ;
71- self . forceUpdate ( ) ;
7283 }
7384 } ) ;
7485 } ,
7586
76- componentWillUnmount : function ( ) {
77- // dis.dispatch({
78- // action: 'ui_opacity',
79- // sideOpacity: 1.0,
80- // middleOpacity: 1.0,
81- // });
87+ deleteAliasClicked : function ( roomAlias ) {
88+ var QuestionDialog = sdk . getComponent ( "dialogs.QuestionDialog" ) ;
89+ var ErrorDialog = sdk . getComponent ( "dialogs.ErrorDialog" ) ;
90+ Modal . createDialog ( QuestionDialog , {
91+ title : "Delete Alias" ,
92+ description : `Are you sure you want to remove the alias '${ roomAlias } '?` ,
93+ onFinished : ( should_delete ) => {
94+ if ( should_delete ) {
95+ var Loader = sdk . getComponent ( "elements.Spinner" ) ;
96+ var modal = Modal . createDialog ( Loader ) ;
97+
98+ MatrixClientPeg . get ( ) . deleteAlias ( roomAlias ) . done ( ( ) => {
99+ modal . close ( ) ;
100+ this . getPublicRooms ( ) ;
101+ } , function ( err ) {
102+ modal . close ( ) ;
103+ Modal . createDialog ( ErrorDialog , {
104+ title : "Failed to delete alias" ,
105+ description : err . toString ( )
106+ } ) ;
107+ } ) ;
108+ }
109+ }
110+ } ) ;
82111 } ,
83112
84- showRoom : function ( roomId , roomAlias ) {
113+ showRoom : function ( roomId , roomAlias , ev ) {
114+ if ( ev . shiftKey ) {
115+ ev . preventDefault ( ) ;
116+ this . deleteAliasClicked ( roomAlias ) ;
117+ return ;
118+ }
119+
85120 // extract the metadata from the publicRooms structure to pass
86121 // as out-of-band data to view_room, because we get information
87122 // here that we can't get other than by joining the room in some
@@ -175,7 +210,11 @@ module.exports = React.createClass({
175210 topic = linkifyString ( sanitizeHtml ( topic ) ) ;
176211
177212 rows . unshift (
178- < tr key = { rooms [ i ] . room_id } onClick = { self . showRoom . bind ( null , rooms [ i ] . room_id , alias ) } >
213+ < tr key = { rooms [ i ] . room_id }
214+ onClick = { self . showRoom . bind ( null , rooms [ i ] . room_id , alias ) }
215+ // cancel onMouseDown otherwise shift-clicking highlights text
216+ onMouseDown = { ( ev ) => { ev . preventDefault ( ) ; } }
217+ >
179218 < td className = "mx_RoomDirectory_roomAvatar" >
180219 < BaseAvatar width = { 24 } height = { 24 } resizeMethod = 'crop'
181220 name = { name } idName = { name }
0 commit comments