Merge pull request #597 from matrix-org/dbkr/delete_threepid

Add support for deleting threepids
This commit is contained in:
David Baker 2016-12-22 15:31:34 +00:00 committed by GitHub
commit fd44d9f4d6

View File

@ -248,6 +248,31 @@ module.exports = React.createClass({
this.setState({email_add_pending: true});
},
onRemoveThreepidClicked: function(threepid) {
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
Modal.createDialog(QuestionDialog, {
title: "Remove Contact Information?",
description: "Remove " + threepid.address + "?",
button: 'Remove',
onFinished: (submit) => {
if (submit) {
this.setState({
phase: "UserSettings.LOADING",
});
MatrixClientPeg.get().deleteThreePid(threepid.medium, threepid.address).then(() => {
return this._refreshFromServer();
}).catch((err) => {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createDialog(ErrorDialog, {
title: "Unable to remove contact information",
description: err.toString(),
});
}).done();
}
},
});
},
onEmailDialogFinished: function(ok) {
if (ok) {
this.verifyEmailAddress();
@ -488,7 +513,6 @@ module.exports = React.createClass({
},
render: function() {
var self = this;
var Loader = sdk.getComponent("elements.Spinner");
switch (this.state.phase) {
case "UserSettings.LOADING":
@ -512,8 +536,8 @@ module.exports = React.createClass({
this.state.avatarUrl ? MatrixClientPeg.get().mxcUrlToHttp(this.state.avatarUrl) : null
);
var threepidsSection = this.state.threepids.map(function(val, pidIndex) {
var id = "email-" + val.address;
var threepidsSection = this.state.threepids.map((val, pidIndex) => {
const id = "3pid-" + val.address;
return (
<div className="mx_UserSettings_profileTableRow" key={pidIndex}>
<div className="mx_UserSettings_profileLabelCell">
@ -522,6 +546,9 @@ module.exports = React.createClass({
<div className="mx_UserSettings_profileInputCell">
<input key={val.address} id={id} value={val.address} disabled />
</div>
<div className="mx_UserSettings_threepidButton">
<img src="img/icon_context_delete.svg" width="14" height="14" alt="Remove" onClick={this.onRemoveThreepidClicked.bind(this, val)} />
</div>
</div>
);
});
@ -542,7 +569,7 @@ module.exports = React.createClass({
blurToCancel={ false }
onValueChanged={ this.onAddThreepidClicked } />
</div>
<div className="mx_UserSettings_addThreepid">
<div className="mx_UserSettings_threepidButton">
<img src="img/plus.svg" width="14" height="14" alt="Add" onClick={ this.onAddThreepidClicked.bind(this, undefined, true) }/>
</div>
</div>