mirror of https://github.com/vector-im/riot-web
Unignore people from the settings
Signed-off-by: Travis Ralston <travpc@gmail.com>pull/21833/head
parent
4df16e8245
commit
4579d20fd0
|
@ -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({
|
module.exports = React.createClass({
|
||||||
displayName: 'UserSettings',
|
displayName: 'UserSettings',
|
||||||
|
|
||||||
|
@ -207,6 +243,7 @@ module.exports = React.createClass({
|
||||||
vectorVersion: undefined,
|
vectorVersion: undefined,
|
||||||
rejectingInvites: false,
|
rejectingInvites: false,
|
||||||
mediaDevices: null,
|
mediaDevices: null,
|
||||||
|
ignoredUsers: []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -228,6 +265,7 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
this._refreshMediaDevices();
|
this._refreshMediaDevices();
|
||||||
|
this._refreshIgnoredUsers();
|
||||||
|
|
||||||
// Bulk rejecting invites:
|
// Bulk rejecting invites:
|
||||||
// /sync won't have had time to return when UserSettings re-renders from state changes, so getRooms()
|
// /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) {
|
onAction: function(payload) {
|
||||||
if (payload.action === "notifier_enabled") {
|
if (payload.action === "notifier_enabled") {
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
|
@ -797,14 +847,16 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderIgnoredUsers: function() {
|
_renderIgnoredUsers: function() {
|
||||||
let ignoredUsers = MatrixClientPeg.get().getIgnoredUsers();
|
if (this.state.ignoredUsers.length > 0) {
|
||||||
if (ignoredUsers.length > 0) {
|
let updateHandler = this._refreshIgnoredUsers;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h3>{ _t("Ignored Users") }</h3>
|
<h3>{ _t("Ignored Users") }</h3>
|
||||||
<div className="mx_UserSettings_section mx_UserSettings_ignoredUsersSection">
|
<div className="mx_UserSettings_section mx_UserSettings_ignoredUsersSection">
|
||||||
<ul>
|
<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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -265,6 +265,7 @@
|
||||||
"Kicks user with given id": "Kicks user with given id",
|
"Kicks user with given id": "Kicks user with given id",
|
||||||
"Labs": "Labs",
|
"Labs": "Labs",
|
||||||
"Ignored Users": "Ignored Users",
|
"Ignored Users": "Ignored Users",
|
||||||
|
"Unignore": "Unignore",
|
||||||
"Last seen": "Last seen",
|
"Last seen": "Last seen",
|
||||||
"Leave room": "Leave room",
|
"Leave room": "Leave room",
|
||||||
"left and rejoined": "left and rejoined",
|
"left and rejoined": "left and rejoined",
|
||||||
|
|
|
@ -232,6 +232,7 @@
|
||||||
"Kicks user with given id": "Kicks user with given id",
|
"Kicks user with given id": "Kicks user with given id",
|
||||||
"Labs": "Labs",
|
"Labs": "Labs",
|
||||||
"Ignored Users": "Ignored Users",
|
"Ignored Users": "Ignored Users",
|
||||||
|
"Unignore": "Unignore",
|
||||||
"Leave room": "Leave room",
|
"Leave room": "Leave room",
|
||||||
"left and rejoined": "left and rejoined",
|
"left and rejoined": "left and rejoined",
|
||||||
"left": "left",
|
"left": "left",
|
||||||
|
|
Loading…
Reference in New Issue