Extract separate add / bind methods on AddThreepid

This commit is contained in:
J. Ryan Stinnett 2019-09-19 15:50:18 +01:00
parent 99b804d567
commit 9a1305bf4a
6 changed files with 45 additions and 17 deletions

View file

@ -62,9 +62,7 @@ export default createReactClass({
return;
}
this._addThreepid = new AddThreepid();
// we always bind emails when registering, so let's do the
// same here.
this._addThreepid.addEmailAddress(emailAddress, true).done(() => {
this._addThreepid.addEmailAddress(emailAddress).done(() => {
Modal.createTrackedDialog('Verification Pending', '', QuestionDialog, {
title: _t("Verification Pending"),
description: _t(

View file

@ -161,7 +161,7 @@ export default class EmailAddresses extends React.Component {
const task = new AddThreepid();
this.setState({verifying: true, continueDisabled: true, addTask: task});
task.addEmailAddress(email, false).then(() => {
task.addEmailAddress(email).then(() => {
this.setState({continueDisabled: false});
}).catch((err) => {
console.error("Unable to add email address " + email + " " + err);

View file

@ -158,7 +158,7 @@ export default class PhoneNumbers extends React.Component {
const task = new AddThreepid();
this.setState({verifying: true, continueDisabled: true, addTask: task});
task.addMsisdn(phoneCountry, phoneNumber, false).then((response) => {
task.addMsisdn(phoneCountry, phoneNumber).then((response) => {
this.setState({continueDisabled: false, verifyMsisdn: response.msisdn});
}).catch((err) => {
console.error("Unable to add phone number " + phoneNumber + " " + err);

View file

@ -82,7 +82,11 @@ export class EmailAddress extends React.Component {
// it with IS binding enabled.
// See https://github.com/matrix-org/matrix-doc/pull/2140/files#r311462052
await MatrixClientPeg.get().deleteThreePid(medium, address);
await task.addEmailAddress(address, bind);
if (bind) {
await task.bindEmailAddress(address);
} else {
await task.addEmailAddress(address);
}
this.setState({
continueDisabled: false,
bound: bind,

View file

@ -78,7 +78,11 @@ export class PhoneNumber extends React.Component {
// a leading plus sign to a number in E.164 format (which the 3PID
// address is), but this goes against the spec.
// See https://github.com/matrix-org/matrix-doc/issues/2222
await task.addMsisdn(null, `+${address}`, bind);
if (bind) {
await task.bindMsisdn(null, `+${address}`);
} else {
await task.addMsisdn(null, `+${address}`);
}
this.setState({
continueDisabled: false,
bound: bind,