@@ -979,7 +979,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
979979 * Whether to send public or private receipts.
980980 */
981981 private async determineReceiptType ( client : MatrixClient ) : Promise < ReceiptType > {
982- const roomId = this . props . timelineSet . room . roomId ;
982+ const roomId = this . props . timelineSet . room ? .roomId ?? null ;
983983 const shouldSendPublicReadReceipts = SettingsStore . getValue ( "sendReadReceipts" , roomId ) ;
984984
985985 if ( shouldSendPublicReadReceipts ) {
@@ -1000,7 +1000,12 @@ class TimelinePanel extends React.Component<IProps, IState> {
10001000 /**
10011001 * Whether a fully_read marker should be send.
10021002 */
1003- private shouldSendRM ( ) : boolean {
1003+ private shouldSendRM ( readMarkerEventId : string | null ) : readMarkerEventId is string {
1004+ if ( ! this . state . readMarkerEventId ) {
1005+ // Nothing that can be send.
1006+ return false ;
1007+ }
1008+
10041009 if ( this . lastRRSentEventId && this . lastRMSentEventId === this . state . readMarkerEventId ) {
10051010 // Prevent sending the same receipt twice.
10061011 return false ;
@@ -1082,9 +1087,10 @@ class TimelinePanel extends React.Component<IProps, IState> {
10821087 lastReadEvent ,
10831088 lastReadEventIndex ,
10841089 ) ;
1085- const shouldSendRM = this . shouldSendRM ( ) ;
1090+ const readMarkerEventId = this . state . readMarkerEventId ;
1091+ const shouldSendRM = this . shouldSendRM ( readMarkerEventId ) ;
10861092
1087- debuglog ( `Sending Read Markers for ${ this . props . timelineSet . room . roomId } : ` , {
1093+ debuglog ( `Sending Read Markers for ${ this . props . timelineSet . room ? .roomId } : ` , {
10881094 shouldSendRR,
10891095 shouldSendRM,
10901096 currentRREventId,
@@ -1101,7 +1107,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
11011107 }
11021108
11031109 if ( shouldSendRM ) {
1104- const readMarkerEvent = this . props . timelineSet . findEventById ( this . state . readMarkerEventId ) ;
1110+ const readMarkerEvent = this . props . timelineSet . findEventById ( readMarkerEventId ) ;
11051111
11061112 if ( readMarkerEvent ) {
11071113 proms . push ( await this . sendReadMarker ( client , readMarkerEvent ) ) ;
@@ -1126,7 +1132,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
11261132 this . lastRRSentEventId = undefined ;
11271133
11281134 logger . error ( "Error sending receipt" , {
1129- room : this . props . timelineSet . room . roomId ,
1135+ room : this . props . timelineSet . room ? .roomId ,
11301136 error : err ,
11311137 } ) ;
11321138 }
@@ -1146,7 +1152,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
11461152 this . lastRMSentEventId = undefined ;
11471153
11481154 logger . error ( "Error sending fully_read" , {
1149- room : this . props . timelineSet . room . roomId ,
1155+ room : this . props . timelineSet . room ? .roomId ,
11501156 error : err ,
11511157 } ) ;
11521158 }
0 commit comments