@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- import React from "react" ;
17+ import React , { ReactNode } from "react" ;
1818import { IGeneratedSas , ISasEvent , SasEvent } from "matrix-js-sdk/src/crypto/verification/SAS" ;
1919import { VerificationBase , VerificationEvent } from "matrix-js-sdk/src/crypto/verification/Base" ;
2020import { logger } from "matrix-js-sdk/src/logger" ;
@@ -48,13 +48,13 @@ interface IState {
4848 // eslint-disable-next-line camelcase
4949 avatar_url ?: string ;
5050 displayname ?: string ;
51- } ;
52- opponentProfileError : Error ;
53- sas : IGeneratedSas ;
51+ } | null ;
52+ opponentProfileError : Error | null ;
53+ sas : IGeneratedSas | null ;
5454}
5555
5656export default class IncomingSasDialog extends React . Component < IProps , IState > {
57- private showSasEvent : ISasEvent ;
57+ private showSasEvent : ISasEvent | null ;
5858
5959 public constructor ( props : IProps ) {
6060 super ( props ) ;
@@ -93,7 +93,7 @@ export default class IncomingSasDialog extends React.Component<IProps, IState> {
9393 } ) ;
9494 } catch ( e ) {
9595 this . setState ( {
96- opponentProfileError : e ,
96+ opponentProfileError : e as Error ,
9797 } ) ;
9898 }
9999 }
@@ -133,7 +133,7 @@ export default class IncomingSasDialog extends React.Component<IProps, IState> {
133133 } ;
134134
135135 private onSasMatchesClick = ( ) : void => {
136- this . showSasEvent . confirm ( ) ;
136+ this . showSasEvent ? .confirm ( ) ;
137137 this . setState ( {
138138 phase : PHASE_WAIT_FOR_PARTNER_TO_CONFIRM ,
139139 } ) ;
@@ -143,7 +143,7 @@ export default class IncomingSasDialog extends React.Component<IProps, IState> {
143143 this . props . onFinished ( true ) ;
144144 } ;
145145
146- private renderPhaseStart ( ) : JSX . Element {
146+ private renderPhaseStart ( ) : ReactNode {
147147 const isSelf = this . props . verifier . userId === MatrixClientPeg . get ( ) . getUserId ( ) ;
148148
149149 let profile ;
@@ -227,7 +227,8 @@ export default class IncomingSasDialog extends React.Component<IProps, IState> {
227227 ) ;
228228 }
229229
230- private renderPhaseShowSas ( ) : JSX . Element {
230+ private renderPhaseShowSas ( ) : ReactNode {
231+ if ( ! this . showSasEvent ) return null ;
231232 return (
232233 < VerificationShowSas
233234 sas = { this . showSasEvent . sas }
@@ -239,7 +240,7 @@ export default class IncomingSasDialog extends React.Component<IProps, IState> {
239240 ) ;
240241 }
241242
242- private renderPhaseWaitForPartnerToConfirm ( ) : JSX . Element {
243+ private renderPhaseWaitForPartnerToConfirm ( ) : ReactNode {
243244 return (
244245 < div >
245246 < Spinner />
@@ -248,15 +249,15 @@ export default class IncomingSasDialog extends React.Component<IProps, IState> {
248249 ) ;
249250 }
250251
251- private renderPhaseVerified ( ) : JSX . Element {
252+ private renderPhaseVerified ( ) : ReactNode {
252253 return < VerificationComplete onDone = { this . onVerifiedDoneClick } /> ;
253254 }
254255
255- private renderPhaseCancelled ( ) : JSX . Element {
256+ private renderPhaseCancelled ( ) : ReactNode {
256257 return < VerificationCancelled onDone = { this . onCancelClick } /> ;
257258 }
258259
259- public render ( ) : React . ReactNode {
260+ public render ( ) : ReactNode {
260261 let body ;
261262 switch ( this . state . phase ) {
262263 case PHASE_START :
0 commit comments