@@ -16,15 +16,14 @@ limitations under the License.
16
16
17
17
import React from "react" ;
18
18
import { verificationMethods } from "matrix-js-sdk/src/crypto" ;
19
- import { ReciprocateQRCode , SCAN_QR_CODE_METHOD } from "matrix-js-sdk/src/crypto/verification/QRCode" ;
19
+ import { SCAN_QR_CODE_METHOD } from "matrix-js-sdk/src/crypto/verification/QRCode" ;
20
20
import {
21
21
Phase ,
22
22
VerificationRequest ,
23
23
VerificationRequestEvent ,
24
24
} from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest" ;
25
25
import { RoomMember } from "matrix-js-sdk/src/models/room-member" ;
26
26
import { User } from "matrix-js-sdk/src/models/user" ;
27
- import { SAS } from "matrix-js-sdk/src/crypto/verification/SAS" ;
28
27
import { logger } from "matrix-js-sdk/src/logger" ;
29
28
import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo" ;
30
29
import { ShowQrCodeCallbacks , ShowSasCallbacks , VerifierEvent } from "matrix-js-sdk/src/crypto-api/verification" ;
@@ -49,18 +48,18 @@ interface IProps {
49
48
}
50
49
51
50
interface IState {
52
- sasEvent ? : ShowSasCallbacks ;
51
+ sasEvent : ShowSasCallbacks | null ;
53
52
emojiButtonClicked ?: boolean ;
54
53
reciprocateButtonClicked ?: boolean ;
55
- reciprocateQREvent ? : ShowQrCodeCallbacks ;
54
+ reciprocateQREvent : ShowQrCodeCallbacks | null ;
56
55
}
57
56
58
57
export default class VerificationPanel extends React . PureComponent < IProps , IState > {
59
58
private hasVerifier : boolean ;
60
59
61
60
public constructor ( props : IProps ) {
62
61
super ( props ) ;
63
- this . state = { } ;
62
+ this . state = { sasEvent : null , reciprocateQREvent : null } ;
64
63
this . hasVerifier = false ;
65
64
}
66
65
@@ -399,11 +398,12 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
399
398
} ;
400
399
401
400
private updateVerifierState = ( ) : void => {
402
- const { request } = this . props ;
403
- const sasEvent = ( request . verifier as SAS ) . sasEvent ;
404
- const reciprocateQREvent = ( request . verifier as ReciprocateQRCode ) . reciprocateQREvent ;
405
- request . verifier ?. off ( VerifierEvent . ShowSas , this . updateVerifierState ) ;
406
- request . verifier ?. off ( VerifierEvent . ShowReciprocateQr , this . updateVerifierState ) ;
401
+ // this method is only called once we know there is a verifier.
402
+ const verifier = this . props . request . verifier ! ;
403
+ const sasEvent = verifier . getShowSasCallbacks ( ) ;
404
+ const reciprocateQREvent = verifier . getReciprocateQrCodeCallbacks ( ) ;
405
+ verifier . off ( VerifierEvent . ShowSas , this . updateVerifierState ) ;
406
+ verifier . off ( VerifierEvent . ShowReciprocateQr , this . updateVerifierState ) ;
407
407
this . setState ( { sasEvent, reciprocateQREvent } ) ;
408
408
} ;
409
409
@@ -428,8 +428,8 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
428
428
const { request } = this . props ;
429
429
request . on ( VerificationRequestEvent . Change , this . onRequestChange ) ;
430
430
if ( request . verifier ) {
431
- const sasEvent = ( request . verifier as SAS ) . sasEvent ;
432
- const reciprocateQREvent = ( request . verifier as ReciprocateQRCode ) . reciprocateQREvent ;
431
+ const sasEvent = request . verifier . getShowSasCallbacks ( ) ;
432
+ const reciprocateQREvent = request . verifier . getReciprocateQrCodeCallbacks ( ) ;
433
433
this . setState ( { sasEvent, reciprocateQREvent } ) ;
434
434
}
435
435
this . onRequestChange ( ) ;
0 commit comments