Warn on disconnecting from IS
...if the user has bound threepids Fixes https://github.com/vector-im/riot-web/issues/10550
This commit is contained in:
parent
088dc7953b
commit
75770f7a4a
4 changed files with 53 additions and 64 deletions
|
@ -24,6 +24,7 @@ import sdk from '../../../../index';
|
|||
import Modal from '../../../../Modal';
|
||||
import IdentityAuthClient from '../../../../IdentityAuthClient';
|
||||
import AddThreepid from '../../../../AddThreepid';
|
||||
import { getThreepidBindStatus } from '../../../../boundThreepids';
|
||||
|
||||
/*
|
||||
TODO: Improve the UX for everything in here.
|
||||
|
@ -220,28 +221,7 @@ export default class PhoneNumbers extends React.Component {
|
|||
const userId = client.getUserId();
|
||||
|
||||
const { threepids } = await client.getThreePids();
|
||||
const msisdns = threepids.filter((a) => a.medium === 'msisdn');
|
||||
|
||||
if (msisdns.length > 0) {
|
||||
// TODO: Handle terms agreement
|
||||
// See https://github.com/vector-im/riot-web/issues/10522
|
||||
const authClient = new IdentityAuthClient();
|
||||
const identityAccessToken = await authClient.getAccessToken();
|
||||
|
||||
// Restructure for lookup query
|
||||
const query = msisdns.map(({ medium, address }) => [medium, address]);
|
||||
const lookupResults = await client.bulkLookupThreePids(query, identityAccessToken);
|
||||
|
||||
// Record which are already bound
|
||||
for (const [medium, address, mxid] of lookupResults.threepids) {
|
||||
if (medium !== "msisdn" || mxid !== userId) {
|
||||
continue;
|
||||
}
|
||||
const msisdn = msisdns.find(e => e.address === address);
|
||||
if (!msisdn) continue;
|
||||
msisdn.bound = true;
|
||||
}
|
||||
}
|
||||
const msisdns = await getThreepidBindStatus(client, 'msisdn');
|
||||
|
||||
this.setState({ msisdns });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue