Use existing modal promises
parent
d5552e4a17
commit
2ff592c542
|
@ -167,13 +167,14 @@ export default class SetIdServer extends React.Component {
|
||||||
// Double check that the identity server even has terms of service.
|
// Double check that the identity server even has terms of service.
|
||||||
const terms = await MatrixClientPeg.get().getTerms(SERVICE_TYPES.IS, fullUrl);
|
const terms = await MatrixClientPeg.get().getTerms(SERVICE_TYPES.IS, fullUrl);
|
||||||
if (!terms || !terms["policies"] || Object.keys(terms["policies"]).length <= 0) {
|
if (!terms || !terms["policies"] || Object.keys(terms["policies"]).length <= 0) {
|
||||||
save &= await this._showNoTermsWarning(fullUrl);
|
const [confirmed] = await this._showNoTermsWarning(fullUrl);
|
||||||
|
save &= confirmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show a general warning, possibly with details about any bound
|
// Show a general warning, possibly with details about any bound
|
||||||
// 3PIDs that would be left behind.
|
// 3PIDs that would be left behind.
|
||||||
if (this.state.currentClientIdServer) {
|
if (save && this.state.currentClientIdServer) {
|
||||||
save &= await this._showServerChangeWarning({
|
const [confirmed] = await this._showServerChangeWarning({
|
||||||
title: _t("Change identity server"),
|
title: _t("Change identity server"),
|
||||||
unboundMessage: _t(
|
unboundMessage: _t(
|
||||||
"Disconnect from the identity server <current /> and " +
|
"Disconnect from the identity server <current /> and " +
|
||||||
|
@ -185,6 +186,7 @@ export default class SetIdServer extends React.Component {
|
||||||
),
|
),
|
||||||
button: _t("Continue"),
|
button: _t("Continue"),
|
||||||
});
|
});
|
||||||
|
save &= confirmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (save) {
|
if (save) {
|
||||||
|
@ -209,29 +211,27 @@ export default class SetIdServer extends React.Component {
|
||||||
|
|
||||||
_showNoTermsWarning(fullUrl) {
|
_showNoTermsWarning(fullUrl) {
|
||||||
const QuestionDialog = sdk.getComponent("views.dialogs.QuestionDialog");
|
const QuestionDialog = sdk.getComponent("views.dialogs.QuestionDialog");
|
||||||
return new Promise(resolve => {
|
const { finished } = Modal.createTrackedDialog('No Terms Warning', '', QuestionDialog, {
|
||||||
Modal.createTrackedDialog('No Terms Warning', '', QuestionDialog, {
|
title: _t("Identity server has no terms of service"),
|
||||||
title: _t("Identity server has no terms of service"),
|
description: (
|
||||||
description: (
|
<div>
|
||||||
<div>
|
<span className="warning">
|
||||||
<span className="warning">
|
{_t("The identity server you have chosen does not have any terms of service.")}
|
||||||
{_t("The identity server you have chosen does not have any terms of service.")}
|
</span>
|
||||||
</span>
|
<span>
|
||||||
<span>
|
{_t("Only continue if you trust the owner of the server.")}
|
||||||
{_t("Only continue if you trust the owner of the server.")}
|
</span>
|
||||||
</span>
|
</div>
|
||||||
</div>
|
),
|
||||||
),
|
button: _t("Continue"),
|
||||||
button: _t("Continue"),
|
|
||||||
onFinished: resolve,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
return finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
_onDisconnectClicked = async () => {
|
_onDisconnectClicked = async () => {
|
||||||
this.setState({disconnectBusy: true});
|
this.setState({disconnectBusy: true});
|
||||||
try {
|
try {
|
||||||
const confirmed = await this._showServerChangeWarning({
|
const [confirmed] = await this._showServerChangeWarning({
|
||||||
title: _t("Disconnect identity server"),
|
title: _t("Disconnect identity server"),
|
||||||
unboundMessage: _t(
|
unboundMessage: _t(
|
||||||
"Disconnect from the identity server <idserver />?", {},
|
"Disconnect from the identity server <idserver />?", {},
|
||||||
|
@ -268,14 +268,12 @@ export default class SetIdServer extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
||||||
return new Promise(resolve => {
|
const { finished } = Modal.createTrackedDialog('Identity Server Bound Warning', '', QuestionDialog, {
|
||||||
Modal.createTrackedDialog('Identity Server Bound Warning', '', QuestionDialog, {
|
title,
|
||||||
title,
|
description: message,
|
||||||
description: message,
|
button,
|
||||||
button,
|
|
||||||
onFinished: resolve,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
return finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
_disconnectIdServer = () => {
|
_disconnectIdServer = () => {
|
||||||
|
|
Loading…
Reference in New Issue