@@ -176,6 +176,34 @@ const THEMES = [
176
176
} ,
177
177
] ;
178
178
179
+ const IgnoredUser = React . createClass ( {
180
+ propTypes : {
181
+ userId : React . PropTypes . string . isRequired ,
182
+ onUnignored : React . PropTypes . func . isRequired ,
183
+ } ,
184
+
185
+ _onUnignoreClick : function ( ) {
186
+ const ignoredUsers = MatrixClientPeg . get ( ) . getIgnoredUsers ( ) ;
187
+ const index = ignoredUsers . indexOf ( this . props . userId ) ;
188
+ if ( index !== - 1 ) {
189
+ ignoredUsers . splice ( index , 1 ) ;
190
+ MatrixClientPeg . get ( ) . setIgnoredUsers ( ignoredUsers )
191
+ . then ( ( ) => this . props . onUnignored ( this . props . userId ) ) ;
192
+ } else this . props . onUnignored ( this . props . userId ) ;
193
+ } ,
194
+
195
+ render : function ( ) {
196
+ return (
197
+ < li >
198
+ < AccessibleButton onClick = { this . _onUnignoreClick } className = "mx_UserSettings_button mx_UserSettings_buttonSmall" >
199
+ { _t ( "Unignore" ) }
200
+ </ AccessibleButton >
201
+ { this . props . userId }
202
+ </ li >
203
+ ) ;
204
+ } ,
205
+ } ) ;
206
+
179
207
module . exports = React . createClass ( {
180
208
displayName : 'UserSettings' ,
181
209
@@ -211,6 +239,7 @@ module.exports = React.createClass({
211
239
vectorVersion : undefined ,
212
240
rejectingInvites : false ,
213
241
mediaDevices : null ,
242
+ ignoredUsers : [ ] ,
214
243
} ;
215
244
} ,
216
245
@@ -232,6 +261,7 @@ module.exports = React.createClass({
232
261
}
233
262
234
263
this . _refreshMediaDevices ( ) ;
264
+ this . _refreshIgnoredUsers ( ) ;
235
265
236
266
// Bulk rejecting invites:
237
267
// /sync won't have had time to return when UserSettings re-renders from state changes, so getRooms()
@@ -350,9 +380,22 @@ module.exports = React.createClass({
350
380
} ) ;
351
381
} ,
352
382
383
+ _refreshIgnoredUsers : function ( userIdUnignored = null ) {
384
+ const users = MatrixClientPeg . get ( ) . getIgnoredUsers ( ) ;
385
+ if ( userIdUnignored ) {
386
+ const index = users . indexOf ( userIdUnignored ) ;
387
+ if ( index !== - 1 ) users . splice ( index , 1 ) ;
388
+ }
389
+ this . setState ( {
390
+ ignoredUsers : users ,
391
+ } ) ;
392
+ } ,
393
+
353
394
onAction : function ( payload ) {
354
395
if ( payload . action === "notifier_enabled" ) {
355
396
this . forceUpdate ( ) ;
397
+ } else if ( payload . action === "ignore_state_changed" ) {
398
+ this . _refreshIgnoredUsers ( ) ;
356
399
}
357
400
} ,
358
401
@@ -800,6 +843,26 @@ module.exports = React.createClass({
800
843
) ;
801
844
} ,
802
845
846
+ _renderIgnoredUsers : function ( ) {
847
+ if ( this . state . ignoredUsers . length > 0 ) {
848
+ const updateHandler = this . _refreshIgnoredUsers ;
849
+ return (
850
+ < div >
851
+ < h3 > { _t ( "Ignored Users" ) } </ h3 >
852
+ < div className = "mx_UserSettings_section mx_UserSettings_ignoredUsersSection" >
853
+ < ul >
854
+ { this . state . ignoredUsers . map ( function ( userId ) {
855
+ return ( < IgnoredUser key = { userId }
856
+ userId = { userId }
857
+ onUnignored = { updateHandler } > </ IgnoredUser > ) ;
858
+ } ) }
859
+ </ ul >
860
+ </ div >
861
+ </ div >
862
+ ) ;
863
+ } else return ( < div /> ) ;
864
+ } ,
865
+
803
866
_renderLocalSetting : function ( setting ) {
804
867
// TODO: this ought to be a separate component so that we don't need
805
868
// to rebind the onChange each time we render
@@ -1306,6 +1369,7 @@ module.exports = React.createClass({
1306
1369
{ this . _renderWebRtcSettings ( ) }
1307
1370
{ this . _renderDevicesPanel ( ) }
1308
1371
{ this . _renderCryptoInfo ( ) }
1372
+ { this . _renderIgnoredUsers ( ) }
1309
1373
{ this . _renderBulkOptions ( ) }
1310
1374
{ this . _renderBugReport ( ) }
1311
1375
0 commit comments