From 2040587826ff56372cd783d72ed9c8bab53f53fc Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 9 Oct 2019 10:47:34 +0100 Subject: [PATCH] Return promises --- src/AddThreepid.js | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/AddThreepid.js b/src/AddThreepid.js index f4a2a88b36..0f09264295 100644 --- a/src/AddThreepid.js +++ b/src/AddThreepid.js @@ -188,11 +188,20 @@ export default class AddThreepid { // pop up an interactive auth dialog const InteractiveAuthDialog = sdk.getComponent("dialogs.InteractiveAuthDialog"); - Modal.createTrackedDialog('Add Email', '', InteractiveAuthDialog, { - title: _t("Add Email Address"), - matrixClient: MatrixClientPeg.get(), - authData: e.data, - makeRequest: this._makeAddThreepidOnlyRequest, + return new Promise((resolve, reject) => { + Modal.createTrackedDialog('Add Email', '', InteractiveAuthDialog, { + title: _t("Add Email Address"), + matrixClient: MatrixClientPeg.get(), + authData: e.data, + makeRequest: this._makeAddThreepidOnlyRequest, + onFinished: (success) => { + if (success) { + resolve(); + } else { + reject(); + } + }, + }); }); } } @@ -280,11 +289,20 @@ export default class AddThreepid { // pop up an interactive auth dialog const InteractiveAuthDialog = sdk.getComponent("dialogs.InteractiveAuthDialog"); - Modal.createTrackedDialog('Add MSISDN', '', InteractiveAuthDialog, { - title: _t("Add Phone Number"), - matrixClient: MatrixClientPeg.get(), - authData: e.data, - makeRequest: this._makeAddThreepidOnlyRequest, + return new Promise((resolve, reject) => { + Modal.createTrackedDialog('Add MSISDN', '', InteractiveAuthDialog, { + title: _t("Add Phone Number"), + matrixClient: MatrixClientPeg.get(), + authData: e.data, + makeRequest: this._makeAddThreepidOnlyRequest, + onFinished: (success) => { + if (success) { + resolve(); + } else { + reject(); + } + }, + }); }); } }