@@ -6,6 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
6
6
Please see LICENSE files in the repository root for full details.
7
7
*/
8
8
9
+ import classNames from "classnames" ;
9
10
import React , { forwardRef , ForwardRefExoticComponent , useContext } from "react" ;
10
11
import { MatrixEvent } from "matrix-js-sdk/src/matrix" ;
11
12
import { DecryptionFailureCode } from "matrix-js-sdk/src/crypto-api" ;
@@ -45,21 +46,22 @@ function getErrorMessage(mxEvent: MatrixEvent, isVerified: boolean | undefined):
45
46
return _t ( "timeline|decryption_failure|unable_to_decrypt" ) ;
46
47
}
47
48
48
- function getErrorExtraClass ( mxEvent : MatrixEvent ) : string {
49
+ function getErrorExtraClass ( mxEvent : MatrixEvent ) : Record < string , boolean > {
49
50
switch ( mxEvent . decryptionFailureReason ) {
50
51
case DecryptionFailureCode . SENDER_IDENTITY_PREVIOUSLY_VERIFIED :
51
- return " mx_DecryptionFailureVerifiedIdentityChanged" ;
52
+ return { mx_DecryptionFailureVerifiedIdentityChanged : true } ;
52
53
53
54
default :
54
- return "" ;
55
+ return { } ;
55
56
}
56
57
}
57
58
58
59
// A placeholder element for messages that could not be decrypted
59
60
export const DecryptionFailureBody = forwardRef < HTMLDivElement , IBodyProps > ( ( { mxEvent } , ref ) : React . JSX . Element => {
60
61
const verificationState = useContext ( LocalDeviceVerificationStateContext ) ;
62
+ const classes = classNames ( "mx_DecryptionFailureBody" , "mx_EventTile_content" , getErrorExtraClass ( mxEvent ) ) ;
61
63
return (
62
- < div className = { "mx_DecryptionFailureBody mx_EventTile_content" + getErrorExtraClass ( mxEvent ) } ref = { ref } >
64
+ < div className = { classes } ref = { ref } >
63
65
{ getErrorMessage ( mxEvent , verificationState ) }
64
66
</ div >
65
67
) ;
0 commit comments