From 5e10ec4ecec326b040e67d4a9ef4b00e021555d7 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 21 Dec 2016 18:49:38 +0000 Subject: [PATCH 1/3] Add support for deleting threepids --- src/components/structures/UserSettings.js | 33 ++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 337384b118..3a90903b7b 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -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((e) => { + 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(); @@ -483,7 +508,6 @@ module.exports = React.createClass({ }, render: function() { - var self = this; var Loader = sdk.getComponent("elements.Spinner"); switch (this.state.phase) { case "UserSettings.LOADING": @@ -507,7 +531,7 @@ module.exports = React.createClass({ this.state.avatarUrl ? MatrixClientPeg.get().mxcUrlToHttp(this.state.avatarUrl) : null ); - var threepidsSection = this.state.threepids.map(function(val, pidIndex) { + var threepidsSection = this.state.threepids.map((val, pidIndex) => { var id = "email-" + val.address; return (
@@ -517,6 +541,9 @@ module.exports = React.createClass({
+
+ Remove +
); }); @@ -537,7 +564,7 @@ module.exports = React.createClass({ blurToCancel={ false } onValueChanged={ this.onAddThreepidClicked } /> -
+
Add
From 98b22460ec1b471a269ad29fd4c4fee6f1fac754 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 22 Dec 2016 15:03:24 +0000 Subject: [PATCH 2/3] They're not all emails anymore --- src/components/structures/UserSettings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 3a90903b7b..54f876abe0 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -532,7 +532,7 @@ module.exports = React.createClass({ ); var threepidsSection = this.state.threepids.map((val, pidIndex) => { - var id = "email-" + val.address; + const id = "3pid-" + val.address; return (
From a6fdbda011cb5db6f66e970238047aaca4e4d570 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 22 Dec 2016 15:26:08 +0000 Subject: [PATCH 3/3] Get variable name right --- src/components/structures/UserSettings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 54f876abe0..58e550a82d 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -261,7 +261,7 @@ module.exports = React.createClass({ }); MatrixClientPeg.get().deleteThreePid(threepid.medium, threepid.address).then(() => { return this._refreshFromServer(); - }).catch((e) => { + }).catch((err) => { const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); Modal.createDialog(ErrorDialog, { title: "Unable to remove contact information",