@@ -396,12 +396,12 @@ export default class EventTile extends React.Component<IProps, IState> {
396396 if ( ! this . props . mxEvent ) return false ;
397397
398398 // Sanity check (should never happen, but we shouldn't explode if it does)
399- const room = MatrixClientPeg . get ( ) . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
399+ const room = this . context . matrixClient . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
400400 if ( ! room ) return false ;
401401
402402 // Quickly check to see if the event was sent by us. If it wasn't, it won't qualify for
403403 // special read receipts.
404- const myUserId = MatrixClientPeg . get ( ) . getUserId ( ) ;
404+ const myUserId = this . context . matrixClient . getUserId ( ) ;
405405 if ( this . props . mxEvent . getSender ( ) !== myUserId ) return false ;
406406
407407 // Finally, determine if the type is relevant to the user. This notably excludes state
@@ -432,7 +432,7 @@ export default class EventTile extends React.Component<IProps, IState> {
432432
433433 // If anyone has read the event besides us, we don't want to show a sent receipt.
434434 const receipts = this . props . readReceipts || [ ] ;
435- const myUserId = MatrixClientPeg . get ( ) . getUserId ( ) ;
435+ const myUserId = this . context . matrixClient . getUserId ( ) ;
436436 if ( receipts . some ( r => r . userId !== myUserId ) ) return false ;
437437
438438 // Finally, we should show a receipt.
@@ -460,7 +460,7 @@ export default class EventTile extends React.Component<IProps, IState> {
460460
461461 componentDidMount ( ) {
462462 this . suppressReadReceiptAnimation = false ;
463- const client = MatrixClientPeg . get ( ) ;
463+ const client = this . context . matrixClient ;
464464 if ( ! this . props . forExport ) {
465465 client . on ( "deviceVerificationChanged" , this . onDeviceVerificationChanged ) ;
466466 client . on ( "userTrustStatusChanged" , this . onUserVerificationChanged ) ;
@@ -480,7 +480,7 @@ export default class EventTile extends React.Component<IProps, IState> {
480480 this . props . mxEvent . on ( ThreadEvent . Update , this . updateThread ) ;
481481 }
482482
483- const room = MatrixClientPeg . get ( ) . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
483+ const room = this . context . matrixClient . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
484484 room ?. on ( ThreadEvent . New , this . onNewThread ) ;
485485 }
486486
@@ -510,7 +510,7 @@ export default class EventTile extends React.Component<IProps, IState> {
510510 }
511511
512512 componentWillUnmount ( ) {
513- const client = MatrixClientPeg . get ( ) ;
513+ const client = this . context . matrixClient ;
514514 client . removeListener ( "deviceVerificationChanged" , this . onDeviceVerificationChanged ) ;
515515 client . removeListener ( "userTrustStatusChanged" , this . onUserVerificationChanged ) ;
516516 client . removeListener ( "Room.receipt" , this . onRoomReceipt ) ;
@@ -524,22 +524,22 @@ export default class EventTile extends React.Component<IProps, IState> {
524524 this . props . mxEvent . off ( ThreadEvent . Update , this . updateThread ) ;
525525 }
526526
527- const room = MatrixClientPeg . get ( ) . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
527+ const room = this . context . matrixClient . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
528528 room ?. off ( ThreadEvent . New , this . onNewThread ) ;
529529 }
530530
531531 componentDidUpdate ( prevProps , prevState , snapshot ) {
532532 // If we're not listening for receipts and expect to be, register a listener.
533533 if ( ! this . isListeningForReceipts && ( this . shouldShowSentReceipt || this . shouldShowSendingReceipt ) ) {
534- MatrixClientPeg . get ( ) . on ( "Room.receipt" , this . onRoomReceipt ) ;
534+ this . context . matrixClient . on ( "Room.receipt" , this . onRoomReceipt ) ;
535535 this . isListeningForReceipts = true ;
536536 }
537537 }
538538
539539 private onNewThread = ( thread : Thread ) => {
540540 if ( thread . id === this . props . mxEvent . getId ( ) ) {
541541 this . updateThread ( thread ) ;
542- const room = MatrixClientPeg . get ( ) . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
542+ const room = this . context . matrixClient . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
543543 room . off ( ThreadEvent . New , this . onNewThread ) ;
544544 }
545545 } ;
@@ -555,7 +555,7 @@ export default class EventTile extends React.Component<IProps, IState> {
555555 * We currently have no reliable way to discover than an event is a thread
556556 * when we are at the sync stage
557557 */
558- const room = MatrixClientPeg . get ( ) . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
558+ const room = this . context . matrixClient . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
559559 const thread = room ?. threads . get ( this . props . mxEvent . getId ( ) ) ;
560560
561561 if ( thread && ! thread . ready ) {
@@ -600,7 +600,7 @@ export default class EventTile extends React.Component<IProps, IState> {
600600
601601 private onRoomReceipt = ( ev , room ) => {
602602 // ignore events for other rooms
603- const tileRoom = MatrixClientPeg . get ( ) . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
603+ const tileRoom = this . context . matrixClient . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
604604 if ( room !== tileRoom ) return ;
605605
606606 if ( ! this . shouldShowSentReceipt && ! this . shouldShowSendingReceipt && ! this . isListeningForReceipts ) {
@@ -612,7 +612,7 @@ export default class EventTile extends React.Component<IProps, IState> {
612612 this . forceUpdate ( ( ) => {
613613 // Per elsewhere in this file, we can remove the listener once we will have no further purpose for it.
614614 if ( ! this . shouldShowSentReceipt && ! this . shouldShowSendingReceipt ) {
615- MatrixClientPeg . get ( ) . removeListener ( "Room.receipt" , this . onRoomReceipt ) ;
615+ this . context . matrixClient . removeListener ( "Room.receipt" , this . onRoomReceipt ) ;
616616 this . isListeningForReceipts = false ;
617617 }
618618 } ) ;
@@ -645,9 +645,9 @@ export default class EventTile extends React.Component<IProps, IState> {
645645 return ;
646646 }
647647
648- const encryptionInfo = MatrixClientPeg . get ( ) . getEventEncryptionInfo ( mxEvent ) ;
648+ const encryptionInfo = this . context . matrixClient . getEventEncryptionInfo ( mxEvent ) ;
649649 const senderId = mxEvent . getSender ( ) ;
650- const userTrust = MatrixClientPeg . get ( ) . checkUserTrust ( senderId ) ;
650+ const userTrust = this . context . matrixClient . checkUserTrust ( senderId ) ;
651651
652652 if ( encryptionInfo . mismatchedSender ) {
653653 // something definitely wrong is going on here
@@ -665,7 +665,7 @@ export default class EventTile extends React.Component<IProps, IState> {
665665 return ;
666666 }
667667
668- const eventSenderTrust = encryptionInfo . sender && MatrixClientPeg . get ( ) . checkDeviceTrust (
668+ const eventSenderTrust = encryptionInfo . sender && this . context . matrixClient . checkDeviceTrust (
669669 senderId , encryptionInfo . sender . deviceId ,
670670 ) ;
671671 if ( ! eventSenderTrust ) {
@@ -744,13 +744,13 @@ export default class EventTile extends React.Component<IProps, IState> {
744744
745745 shouldHighlight ( ) {
746746 if ( this . props . forExport ) return false ;
747- const actions = MatrixClientPeg . get ( ) . getPushActionsForEvent (
747+ const actions = this . context . matrixClient . getPushActionsForEvent (
748748 this . props . mxEvent . replacingEvent ( ) || this . props . mxEvent ,
749749 ) ;
750750 if ( ! actions || ! actions . tweaks ) { return false ; }
751751
752752 // don't show self-highlights from another of our clients
753- if ( this . props . mxEvent . getSender ( ) === MatrixClientPeg . get ( ) . credentials . userId ) {
753+ if ( this . props . mxEvent . getSender ( ) === this . context . matrixClient . credentials . userId ) {
754754 return false ;
755755 }
756756
@@ -876,7 +876,7 @@ export default class EventTile extends React.Component<IProps, IState> {
876876 // Cancel any outgoing key request for this event and resend it. If a response
877877 // is received for the request with the required keys, the event could be
878878 // decrypted successfully.
879- MatrixClientPeg . get ( ) . cancelAndResendEventRoomKeyRequest ( this . props . mxEvent ) ;
879+ this . context . matrixClient . cancelAndResendEventRoomKeyRequest ( this . props . mxEvent ) ;
880880 } ;
881881
882882 onPermalinkClicked = e => {
@@ -914,7 +914,7 @@ export default class EventTile extends React.Component<IProps, IState> {
914914 }
915915 }
916916
917- if ( MatrixClientPeg . get ( ) . isRoomEncrypted ( ev . getRoomId ( ) ) ) {
917+ if ( this . context . matrixClient . isRoomEncrypted ( ev . getRoomId ( ) ) ) {
918918 // else if room is encrypted
919919 // and event is being encrypted or is not_sent (Unknown Devices/Network Error)
920920 if ( ev . status === EventStatus . ENCRYPTING ) {
@@ -1189,7 +1189,7 @@ export default class EventTile extends React.Component<IProps, IState> {
11891189
11901190 switch ( this . props . tileShape ) {
11911191 case TileShape . Notif : {
1192- const room = MatrixClientPeg . get ( ) . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
1192+ const room = this . context . matrixClient . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
11931193 return React . createElement ( this . props . as || "li" , {
11941194 "className" : classes ,
11951195 "aria-live" : ariaLive ,
@@ -1236,7 +1236,7 @@ export default class EventTile extends React.Component<IProps, IState> {
12361236 isQuoteExpanded = { isQuoteExpanded }
12371237 setQuoteExpanded = { this . setQuoteExpanded }
12381238 /> ) : null ;
1239- const room = MatrixClientPeg . get ( ) . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
1239+ const room = this . context . matrixClient . getRoom ( this . props . mxEvent . getRoomId ( ) ) ;
12401240 return React . createElement ( this . props . as || "li" , {
12411241 "className" : classes ,
12421242 "aria-live" : ariaLive ,
@@ -1320,7 +1320,7 @@ export default class EventTile extends React.Component<IProps, IState> {
13201320 isQuoteExpanded = { isQuoteExpanded }
13211321 setQuoteExpanded = { this . setQuoteExpanded }
13221322 /> ) : null ;
1323- const isOwnEvent = this . props . mxEvent ?. sender ?. userId === MatrixClientPeg . get ( ) . getUserId ( ) ;
1323+ const isOwnEvent = this . props . mxEvent ?. sender ?. userId === this . context . matrixClient . getUserId ( ) ;
13241324
13251325 // tab-index=-1 to allow it to be focusable but do not add tab stop for it, primarily for screen readers
13261326 return (
0 commit comments