mirror of https://github.com/vector-im/riot-web
				
				
				
			Add (un)ignore button to MemberInfo
Signed-off-by: Travis Ralston <travpc@gmail.com>pull/21833/head
							parent
							
								
									13a251e29c
								
							
						
					
					
						commit
						3889df6b08
					
				|  | @ -62,6 +62,7 @@ module.exports = withMatrixClient(React.createClass({ | |||
|             updating: 0, | ||||
|             devicesLoading: true, | ||||
|             devices: null, | ||||
|             isIgnoring: false, | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|  | @ -81,6 +82,8 @@ module.exports = withMatrixClient(React.createClass({ | |||
|         cli.on("RoomState.events", this.onRoomStateEvents); | ||||
|         cli.on("RoomMember.name", this.onRoomMemberName); | ||||
|         cli.on("accountData", this.onAccountData); | ||||
| 
 | ||||
|         this._checkIgnoreState(); | ||||
|     }, | ||||
| 
 | ||||
|     componentDidMount: function() { | ||||
|  | @ -111,6 +114,11 @@ module.exports = withMatrixClient(React.createClass({ | |||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     _checkIgnoreState: function() { | ||||
|         const isIgnoring = this.props.matrixClient.getIgnoredUsers().indexOf(this.props.member.userId) !== -1; | ||||
|         this.setState({isIgnoring: isIgnoring}); | ||||
|     }, | ||||
| 
 | ||||
|     _disambiguateDevices: function(devices) { | ||||
|         var names = Object.create(null); | ||||
|         for (var i = 0; i < devices.length; i++) { | ||||
|  | @ -225,6 +233,18 @@ module.exports = withMatrixClient(React.createClass({ | |||
|         }); | ||||
|     }, | ||||
| 
 | ||||
|     onIgnoreToggle: function() { | ||||
|         const ignoredUsers = this.props.matrixClient.getIgnoredUsers(); | ||||
|         if (this.state.isIgnoring) { | ||||
|             const index = ignoredUsers.indexOf(this.props.member.userId); | ||||
|             if (index !== -1) ignoredUsers.splice(index, 1); | ||||
|         } else { | ||||
|             ignoredUsers.push(this.props.member.userId); | ||||
|         } | ||||
| 
 | ||||
|         this.props.matrixClient.setIgnoredUsers(ignoredUsers).then(() => this.setState({isIgnoring: !this.state.isIgnoring})); | ||||
|     }, | ||||
| 
 | ||||
|     onKick: function() { | ||||
|         const membership = this.props.member.membership; | ||||
|         const kickLabel = membership === "invite" ? _t("Disinvite") : _t("Kick"); | ||||
|  | @ -607,6 +627,29 @@ module.exports = withMatrixClient(React.createClass({ | |||
|         ); | ||||
|     }, | ||||
| 
 | ||||
|     _renderUserOptions: function() { | ||||
|         // Only allow the user to ignore the user if its not ourselves
 | ||||
|         let ignoreButton = null; | ||||
|         if (this.props.member.userId !== this.props.matrixClient.getUserId()) { | ||||
|             ignoreButton = ( | ||||
|                 <AccessibleButton onClick={this.onIgnoreToggle} className="mx_MemberInfo_field"> | ||||
|                     {this.state.isIgnoring ? _t("Unignore") : _t("Ignore")} | ||||
|                 </AccessibleButton> | ||||
|             ); | ||||
|         } | ||||
| 
 | ||||
|         if (!ignoreButton) return null; | ||||
| 
 | ||||
|         return ( | ||||
|             <div> | ||||
|                 <h3>{ _t("User Options") }</h3> | ||||
|                 <div className="mx_MemberInfo_buttons"> | ||||
|                     {ignoreButton} | ||||
|                 </div> | ||||
|             </div> | ||||
|         ); | ||||
|     }, | ||||
| 
 | ||||
|     render: function() { | ||||
|         var startChat, kickButton, banButton, muteButton, giveModButton, spinner; | ||||
|         if (this.props.member.userId !== this.props.matrixClient.credentials.userId) { | ||||
|  | @ -756,6 +799,8 @@ module.exports = withMatrixClient(React.createClass({ | |||
|                         </div> | ||||
|                     </div> | ||||
| 
 | ||||
|                     { this._renderUserOptions() } | ||||
| 
 | ||||
|                     { adminTools } | ||||
| 
 | ||||
|                     { startChat } | ||||
|  |  | |||
|  | @ -265,7 +265,9 @@ | |||
|     "Kicks user with given id": "Kicks user with given id", | ||||
|     "Labs": "Labs", | ||||
|     "Ignored Users": "Ignored Users", | ||||
|     "Ignore": "Ignore", | ||||
|     "Unignore": "Unignore", | ||||
|     "User Options": "User Options", | ||||
|     "You are now ignoring %(userId)s": "You are now ignoring %(userId)s", | ||||
|     "You are no longer ignoring %(userId)s": "You are no longer ignoring %(userId)s", | ||||
|     "Unignored user": "Unignored user", | ||||
|  |  | |||
|  | @ -232,7 +232,9 @@ | |||
|     "Kicks user with given id": "Kicks user with given id", | ||||
|     "Labs": "Labs", | ||||
|     "Ignored Users": "Ignored Users", | ||||
|     "Ignore": "Ignore", | ||||
|     "Unignore": "Unignore", | ||||
|     "User Options": "User Options", | ||||
|     "You are now ignoring %(userId)s": "You are now ignoring %(userId)s", | ||||
|     "You are no longer ignoring %(userId)s": "You are no longer ignoring %(userId)s", | ||||
|     "Unignored user": "Unignored user", | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Travis Ralston
						Travis Ralston