Re-check key backup status when settings opened
Fixes https://github.com/vector-im/riot-web/issues/8524 Requires https://github.com/matrix-org/matrix-js-sdk/pull/840
This commit is contained in:
parent
fb4fd54f6f
commit
d2b4dfce30
1 changed files with 27 additions and 2 deletions
|
@ -42,7 +42,7 @@ export default class KeyBackupPanel extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
this._loadBackupStatus();
|
this._checkKeyBackupStatus();
|
||||||
|
|
||||||
MatrixClientPeg.get().on('crypto.keyBackupStatus', this._onKeyBackupStatus);
|
MatrixClientPeg.get().on('crypto.keyBackupStatus', this._onKeyBackupStatus);
|
||||||
MatrixClientPeg.get().on(
|
MatrixClientPeg.get().on(
|
||||||
|
@ -70,9 +70,32 @@ export default class KeyBackupPanel extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onKeyBackupStatus() {
|
_onKeyBackupStatus() {
|
||||||
|
// This just loads the current backup status rather than forcing
|
||||||
|
// a re-check otherwise we risk causing infinite loops
|
||||||
this._loadBackupStatus();
|
this._loadBackupStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _checkKeyBackupStatus() {
|
||||||
|
try {
|
||||||
|
const {backupInfo, trustInfo} = await MatrixClientPeg.get().checkKeyBackup();
|
||||||
|
this.setState({
|
||||||
|
backupInfo,
|
||||||
|
backupSigStatus: trustInfo,
|
||||||
|
error: null,
|
||||||
|
loading: false,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Unable to fetch check backup status", e);
|
||||||
|
if (this._unmounted) return;
|
||||||
|
this.setState({
|
||||||
|
error: e,
|
||||||
|
backupInfo: null,
|
||||||
|
backupSigStatus: null,
|
||||||
|
loading: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async _loadBackupStatus() {
|
async _loadBackupStatus() {
|
||||||
this.setState({loading: true});
|
this.setState({loading: true});
|
||||||
try {
|
try {
|
||||||
|
@ -80,6 +103,7 @@ export default class KeyBackupPanel extends React.PureComponent {
|
||||||
const backupSigStatus = await MatrixClientPeg.get().isKeyBackupTrusted(backupInfo);
|
const backupSigStatus = await MatrixClientPeg.get().isKeyBackupTrusted(backupInfo);
|
||||||
if (this._unmounted) return;
|
if (this._unmounted) return;
|
||||||
this.setState({
|
this.setState({
|
||||||
|
error: null,
|
||||||
backupInfo,
|
backupInfo,
|
||||||
backupSigStatus,
|
backupSigStatus,
|
||||||
loading: false,
|
loading: false,
|
||||||
|
@ -89,9 +113,10 @@ export default class KeyBackupPanel extends React.PureComponent {
|
||||||
if (this._unmounted) return;
|
if (this._unmounted) return;
|
||||||
this.setState({
|
this.setState({
|
||||||
error: e,
|
error: e,
|
||||||
|
backupInfo: null,
|
||||||
|
backupSigStatus: null,
|
||||||
loading: false,
|
loading: false,
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue