Update cross-signing details on trust changes

This commit is contained in:
J. Ryan Stinnett 2019-12-12 15:42:27 +00:00
parent 6338ee9683
commit 3cbb3c12cd

View file

@ -36,6 +36,8 @@ export default class CrossSigningPanel extends React.PureComponent {
componentDidMount() { componentDidMount() {
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
cli.on("accountData", this.onAccountData); cli.on("accountData", this.onAccountData);
cli.on("userTrustStatusChanged", this.onStatusChanged);
cli.on("crossSigning.keysChanged", this.onStatusChanged);
} }
componentWillUnmount() { componentWillUnmount() {
@ -43,6 +45,8 @@ export default class CrossSigningPanel extends React.PureComponent {
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
if (!cli) return; if (!cli) return;
cli.removeListener("accountData", this.onAccountData); cli.removeListener("accountData", this.onAccountData);
cli.removeListener("userTrustStatusChanged", this.onStatusChanged);
cli.removeListener("crossSigning.keysChanged", this.onStatusChanged);
} }
onAccountData = (event) => { onAccountData = (event) => {
@ -52,6 +56,10 @@ export default class CrossSigningPanel extends React.PureComponent {
} }
}; };
onStatusChanged = () => {
this.setState(this._getUpdatedStatus());
};
_getUpdatedStatus() { _getUpdatedStatus() {
// XXX: Add public accessors if we keep this around in production // XXX: Add public accessors if we keep this around in production
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();