mirror of
https://github.com/element-hq/element-web
synced 2024-11-29 12:58:53 +03:00
Unignore people from the settings
Signed-off-by: Travis Ralston <travpc@gmail.com>
This commit is contained in:
parent
4df16e8245
commit
4579d20fd0
3 changed files with 57 additions and 3 deletions
|
@ -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 = <AccessibleButton className="mx_RoomSettings_unbanButton" onClick={this._onUnbanClick}>
|
||||
{ _t('Unban') }
|
||||
</AccessibleButton>;
|
||||
}
|
||||
|
||||
return (
|
||||
<li>
|
||||
<AccessibleButton onClick={this._onUnignoreClick} className="mx_UserSettings_button mx_UserSettings_buttonSmall">
|
||||
{ _t("Unignore") }
|
||||
</AccessibleButton>
|
||||
{ this.props.userId }
|
||||
</li>
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
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 (
|
||||
<div>
|
||||
<h3>{ _t("Ignored Users") }</h3>
|
||||
<div className="mx_UserSettings_section mx_UserSettings_ignoredUsersSection">
|
||||
<ul>
|
||||
{ignoredUsers.map(u => (<li key={u}>{u}</li>))}
|
||||
{this.state.ignoredUsers.map(function(userId) {
|
||||
return (<IgnoredUser key={userId} userId={userId} onUnignored={updateHandler}></IgnoredUser>);
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue