@@ -943,13 +943,13 @@ class TimelinePanel extends React.Component<IProps, IState> {
943
943
if ( lastReadEventIndex === null ) {
944
944
shouldSendRR = false ;
945
945
}
946
- let lastReadEvent = this . state . events [ lastReadEventIndex ] ;
946
+ let lastReadEvent : MatrixEvent | null = this . state . events [ lastReadEventIndex ] ;
947
947
shouldSendRR = shouldSendRR &&
948
948
// Only send a RR if the last read event is ahead in the timeline relative to
949
949
// the current RR event.
950
950
lastReadEventIndex > currentRREventIndex &&
951
951
// Only send a RR if the last RR set != the one we would send
952
- this . lastRRSentEventId != lastReadEvent . getId ( ) ;
952
+ this . lastRRSentEventId !== lastReadEvent . getId ( ) ;
953
953
954
954
// Only send a RM if the last RM sent != the one we would send
955
955
const shouldSendRM =
@@ -975,33 +975,43 @@ class TimelinePanel extends React.Component<IProps, IState> {
975
975
`prr=${ lastReadEvent ?. getId ( ) } ` ,
976
976
977
977
) ;
978
- MatrixClientPeg . get ( ) . setRoomReadMarkers (
979
- roomId ,
980
- this . state . readMarkerEventId ,
981
- sendRRs ? lastReadEvent : null , // Public read receipt (could be null)
982
- lastReadEvent , // Private read receipt (could be null)
983
- ) . catch ( async ( e ) => {
984
- // /read_markers API is not implemented on this HS, fallback to just RR
985
- if ( e . errcode === 'M_UNRECOGNIZED' && lastReadEvent ) {
986
- const privateField = await getPrivateReadReceiptField ( MatrixClientPeg . get ( ) ) ;
987
- if ( ! sendRRs && ! privateField ) return ;
988
-
989
- try {
990
- return await MatrixClientPeg . get ( ) . sendReadReceipt (
991
- lastReadEvent ,
992
- sendRRs ? ReceiptType . Read : privateField ,
993
- ) ;
994
- } catch ( error ) {
978
+
979
+ if ( this . props . timelineSet . thread && sendRRs ) {
980
+ // There's no support for fully read markers on threads
981
+ // as defined by MSC3771
982
+ cli . sendReadReceipt (
983
+ lastReadEvent ,
984
+ sendRRs ? ReceiptType . Read : ReceiptType . ReadPrivate ,
985
+ ) ;
986
+ } else {
987
+ cli . setRoomReadMarkers (
988
+ roomId ,
989
+ this . state . readMarkerEventId ,
990
+ sendRRs ? lastReadEvent : null , // Public read receipt (could be null)
991
+ lastReadEvent , // Private read receipt (could be null)
992
+ ) . catch ( async ( e ) => {
993
+ // /read_markers API is not implemented on this HS, fallback to just RR
994
+ if ( e . errcode === 'M_UNRECOGNIZED' && lastReadEvent ) {
995
+ const privateField = await getPrivateReadReceiptField ( cli ) ;
996
+ if ( ! sendRRs && ! privateField ) return ;
997
+
998
+ try {
999
+ return await cli . sendReadReceipt (
1000
+ lastReadEvent ,
1001
+ sendRRs ? ReceiptType . Read : privateField ,
1002
+ ) ;
1003
+ } catch ( error ) {
1004
+ logger . error ( e ) ;
1005
+ this . lastRRSentEventId = undefined ;
1006
+ }
1007
+ } else {
995
1008
logger . error ( e ) ;
996
- this . lastRRSentEventId = undefined ;
997
1009
}
998
- } else {
999
- logger . error ( e ) ;
1000
- }
1001
- // it failed, so allow retries next time the user is active
1002
- this . lastRRSentEventId = undefined ;
1003
- this . lastRMSentEventId = undefined ;
1004
- } ) ;
1010
+ // it failed, so allow retries next time the user is active
1011
+ this . lastRRSentEventId = undefined ;
1012
+ this . lastRMSentEventId = undefined ;
1013
+ } ) ;
1014
+ }
1005
1015
1006
1016
// do a quick-reset of our unreadNotificationCount to avoid having
1007
1017
// to wait from the remote echo from the homeserver.
@@ -1654,15 +1664,16 @@ class TimelinePanel extends React.Component<IProps, IState> {
1654
1664
* SDK.
1655
1665
* @return {String } the event ID
1656
1666
*/
1657
- private getCurrentReadReceipt ( ignoreSynthesized = false ) : string {
1667
+ private getCurrentReadReceipt ( ignoreSynthesized = false ) : string | null {
1658
1668
const client = MatrixClientPeg . get ( ) ;
1659
1669
// the client can be null on logout
1660
1670
if ( client == null ) {
1661
1671
return null ;
1662
1672
}
1663
1673
1664
1674
const myUserId = client . credentials . userId ;
1665
- return this . props . timelineSet . room . getEventReadUpTo ( myUserId , ignoreSynthesized ) ;
1675
+ const receiptStore = this . props . timelineSet . thread ?? this . props . timelineSet . room ;
1676
+ return receiptStore . getEventReadUpTo ( myUserId , ignoreSynthesized ) ;
1666
1677
}
1667
1678
1668
1679
private setReadMarker ( eventId : string , eventTs : number , inhibitSetState = false ) : void {
0 commit comments