diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 6c87c6fe0a..966e3cffbb 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -172,6 +172,42 @@ const THEMES = [ }, ]; +const IgnoredUser = React.createClass({ + propTypes: { + userId: React.PropTypes.string.isRequired, + onUnignored: React.PropTypes.func.isRequired, + }, + + _onUnignoreClick: function() { + const ignoredUsers = MatrixClientPeg.get().getIgnoredUsers(); + const index = ignoredUsers.indexOf(this.props.userId); + if (index !== -1) { + ignoredUsers.splice(index, 1); + MatrixClientPeg.get().setIgnoredUsers(ignoredUsers) + .then(() => this.props.onUnignored(this.props.userId)); + } else this.props.onUnignored(this.props.userId); + }, + + render: function() { + let unbanButton; + + if (this.props.canUnban) { + unbanButton = + { _t('Unban') } + ; + } + + return ( +
  • + + { _t("Unignore") } + + { this.props.userId } +
  • + ); + }, +}); + module.exports = React.createClass({ displayName: 'UserSettings', @@ -207,6 +243,7 @@ module.exports = React.createClass({ vectorVersion: undefined, rejectingInvites: false, mediaDevices: null, + ignoredUsers: [] }; }, @@ -228,6 +265,7 @@ module.exports = React.createClass({ } this._refreshMediaDevices(); + this._refreshIgnoredUsers(); // Bulk rejecting invites: // /sync won't have had time to return when UserSettings re-renders from state changes, so getRooms() @@ -346,6 +384,18 @@ module.exports = React.createClass({ }); }, + _refreshIgnoredUsers: function(userIdUnignored=null) { + let users = MatrixClientPeg.get().getIgnoredUsers(); + if (userIdUnignored) { + var index = users.indexOf(userIdUnignored); + if (index !== -1) users.splice(index, 1); + } + console.log("Updating ignored users: "+JSON.stringify(users)); + this.setState({ + ignoredUsers: users + }); + }, + onAction: function(payload) { if (payload.action === "notifier_enabled") { this.forceUpdate(); @@ -797,14 +847,16 @@ module.exports = React.createClass({ }, _renderIgnoredUsers: function() { - let ignoredUsers = MatrixClientPeg.get().getIgnoredUsers(); - if (ignoredUsers.length > 0) { + if (this.state.ignoredUsers.length > 0) { + let updateHandler = this._refreshIgnoredUsers; return (

    { _t("Ignored Users") }

    diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ae98535e51..57870a18e4 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -265,6 +265,7 @@ "Kicks user with given id": "Kicks user with given id", "Labs": "Labs", "Ignored Users": "Ignored Users", + "Unignore": "Unignore", "Last seen": "Last seen", "Leave room": "Leave room", "left and rejoined": "left and rejoined", diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index 5870fe67f3..225d6e28d7 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -232,6 +232,7 @@ "Kicks user with given id": "Kicks user with given id", "Labs": "Labs", "Ignored Users": "Ignored Users", + "Unignore": "Unignore", "Leave room": "Leave room", "left and rejoined": "left and rejoined", "left": "left",