@@ -10,6 +10,7 @@ import {
1010 MatrixEvent ,
1111 RelationType ,
1212 RoomEvent as MatrixRoomEvent ,
13+ MatrixEventEvent ,
1314} from "matrix-js-sdk/src/matrix" ;
1415import { ReactionEventContent } from "matrix-js-sdk/src/types" ;
1516import {
@@ -184,19 +185,21 @@ export const ReactionsProvider = ({
184185 useEffect ( ( ) => {
185186 const reactionTimeouts = new Set < number > ( ) ;
186187 const handleReactionEvent = ( event : MatrixEvent ) : void => {
187- if ( event . isSending ( ) ) {
188- // Skip any events that are still sending.
189- return ;
190- }
188+ // Decrypted events might come from a different room
189+ if ( event . getRoomId ( ) !== room . roomId ) return ;
190+ // Skip any events that are still sending.
191+ if ( event . isSending ( ) ) return ;
191192
192193 const sender = event . getSender ( ) ;
193194 const reactionEventId = event . getId ( ) ;
194- if ( ! sender || ! reactionEventId ) {
195- // Skip any event without a sender or event ID.
196- return ;
197- }
195+ // Skip any event without a sender or event ID.
196+ if ( ! sender || ! reactionEventId ) return ;
198197
199198 if ( event . getType ( ) === ElementCallReactionEventType ) {
199+ room . client
200+ . decryptEventIfNeeded ( event )
201+ . catch ( ( e ) => logger . warn ( `Failed to decrypt ${ event . getId ( ) } ` , e ) ) ;
202+ if ( event . isBeingDecrypted ( ) || event . isDecryptionFailure ( ) ) return ;
200203 const content : ECallReactionEventContent = event . getContent ( ) ;
201204
202205 const membershipEventId = content ?. [ "m.relates_to" ] ?. event_id ;
@@ -295,6 +298,7 @@ export const ReactionsProvider = ({
295298
296299 room . on ( MatrixRoomEvent . Timeline , handleReactionEvent ) ;
297300 room . on ( MatrixRoomEvent . Redaction , handleReactionEvent ) ;
301+ room . client . on ( MatrixEventEvent . Decrypted , handleReactionEvent ) ;
298302
299303 // We listen for a local echo to get the real event ID, as timeline events
300304 // may still be sending.
@@ -303,6 +307,7 @@ export const ReactionsProvider = ({
303307 return ( ) : void => {
304308 room . off ( MatrixRoomEvent . Timeline , handleReactionEvent ) ;
305309 room . off ( MatrixRoomEvent . Redaction , handleReactionEvent ) ;
310+ room . client . off ( MatrixEventEvent . Decrypted , handleReactionEvent ) ;
306311 room . off ( MatrixRoomEvent . LocalEchoUpdated , handleReactionEvent ) ;
307312 reactionTimeouts . forEach ( ( t ) => clearTimeout ( t ) ) ;
308313 // If we're clearing timeouts, we also clear all reactions.
0 commit comments