@@ -15,7 +15,7 @@ import {
1515 type SyncState ,
1616 ClientStoppedError ,
1717} from "matrix-js-sdk/src/matrix" ;
18- import { logger as baseLogger , LogSpan } from "matrix-js-sdk/src/logger" ;
18+ import { logger as baseLogger , type BaseLogger , LogSpan } from "matrix-js-sdk/src/logger" ;
1919import { CryptoEvent , type KeyBackupInfo } from "matrix-js-sdk/src/crypto-api" ;
2020import { type CryptoSessionStateChange } from "@matrix-org/analytics-events/types/typescript/CryptoSessionStateChange" ;
2121import { secureRandomString } from "matrix-js-sdk/src/randomstring" ;
@@ -213,6 +213,7 @@ export default class DeviceListener {
213213 } ;
214214
215215 private onKeyBackupStatusChanged = ( ) : void => {
216+ logger . info ( "Backup status changed" ) ;
216217 this . cachedKeyBackupUploadActive = undefined ;
217218 this . recheck ( ) ;
218219 } ;
@@ -313,6 +314,7 @@ export default class DeviceListener {
313314 private async doRecheck ( ) : Promise < void > {
314315 if ( ! this . running || ! this . client ) return ; // we have been stopped
315316 const logSpan = new LogSpan ( logger , "check_" + secureRandomString ( 4 ) ) ;
317+ logSpan . debug ( "starting recheck..." ) ;
316318
317319 const cli = this . client ;
318320
@@ -355,7 +357,7 @@ export default class DeviceListener {
355357 ( await crypto . getDeviceVerificationStatus ( cli . getSafeUserId ( ) , cli . deviceId ! ) ) ?. crossSigningVerified ,
356358 ) ;
357359
358- const keyBackupUploadActive = await this . isKeyBackupUploadActive ( ) ;
360+ const keyBackupUploadActive = await this . isKeyBackupUploadActive ( logSpan ) ;
359361 const backupDisabled = await this . recheckBackupDisabled ( cli ) ;
360362
361363 // We warn if key backup upload is turned off and we have not explicitly
@@ -579,15 +581,15 @@ export default class DeviceListener {
579581 * trigger an auto-rageshake).
580582 */
581583 private checkKeyBackupStatus = async ( ) : Promise < void > => {
582- if ( ! ( await this . isKeyBackupUploadActive ( ) ) ) {
584+ if ( ! ( await this . isKeyBackupUploadActive ( logger ) ) ) {
583585 dis . dispatch ( { action : Action . ReportKeyBackupNotEnabled } ) ;
584586 }
585587 } ;
586588
587589 /**
588590 * Is key backup enabled? Use a cached answer if we have one.
589591 */
590- private isKeyBackupUploadActive = async ( ) : Promise < boolean > => {
592+ private isKeyBackupUploadActive = async ( logger : BaseLogger ) : Promise < boolean > => {
591593 if ( ! this . client ) {
592594 // To preserve existing behaviour, if there is no client, we
593595 // pretend key backup upload is on.
@@ -611,6 +613,7 @@ export default class DeviceListener {
611613 // Fetch the answer and cache it
612614 const activeKeyBackupVersion = await crypto . getActiveSessionBackupVersion ( ) ;
613615 this . cachedKeyBackupUploadActive = ! ! activeKeyBackupVersion ;
616+ logger . debug ( `Key backup upload is ${ this . cachedKeyBackupUploadActive ? "active" : "inactive" } ` ) ;
614617
615618 return this . cachedKeyBackupUploadActive ;
616619 } ;
0 commit comments