@@ -17,6 +17,8 @@ limitations under the License.
17
17
import { NotificationCountType , Room } from "matrix-js-sdk/src/models/room" ;
18
18
import { Thread } from "matrix-js-sdk/src/models/thread" ;
19
19
import React , { useContext } from "react" ;
20
+ import { ReceiptType } from "matrix-js-sdk/src/@types/read_receipts" ;
21
+ import { ReadReceipt } from "matrix-js-sdk/src/models/read-receipt" ;
20
22
21
23
import MatrixClientContext from "../../../../contexts/MatrixClientContext" ;
22
24
import { useNotificationState } from "../../../../hooks/useRoomNotificationState" ;
@@ -26,6 +28,42 @@ import { humanReadableNotificationColor } from "../../../../stores/notifications
26
28
import { doesRoomOrThreadHaveUnreadMessages } from "../../../../Unread" ;
27
29
import BaseTool , { DevtoolsContext , IDevtoolsProps } from "./BaseTool" ;
28
30
31
+ function UserReadUpTo ( { target } : { target : ReadReceipt < any , any > } ) : JSX . Element {
32
+ const cli = useContext ( MatrixClientContext ) ;
33
+ const userId = cli . getSafeUserId ( ) ;
34
+ const hasPrivate = ! ! target . getReadReceiptForUserId ( userId , false , ReceiptType . ReadPrivate ) ;
35
+ return (
36
+ < >
37
+ < li >
38
+ { _t ( "User read up to: " ) }
39
+ < strong > { target . getReadReceiptForUserId ( userId ) ?. eventId ?? _t ( "No receipt found" ) } </ strong >
40
+ </ li >
41
+ < li >
42
+ { _t ( "User read up to (ignoreSynthetic): " ) }
43
+ < strong > { target . getReadReceiptForUserId ( userId , true ) ?. eventId ?? _t ( "No receipt found" ) } </ strong >
44
+ </ li >
45
+ { hasPrivate && (
46
+ < >
47
+ < li >
48
+ { _t ( "User read up to (m.read.private): " ) }
49
+ < strong >
50
+ { target . getReadReceiptForUserId ( userId , false , ReceiptType . ReadPrivate ) ?. eventId ??
51
+ _t ( "No receipt found" ) }
52
+ </ strong >
53
+ </ li >
54
+ < li >
55
+ { _t ( "User read up to (m.read.private;ignoreSynthetic): " ) }
56
+ < strong >
57
+ { target . getReadReceiptForUserId ( userId , true , ReceiptType . ReadPrivate ) ?. eventId ??
58
+ _t ( "No receipt found" ) }
59
+ </ strong >
60
+ </ li >
61
+ </ >
62
+ ) }
63
+ </ >
64
+ ) ;
65
+ }
66
+
29
67
export default function RoomNotifications ( { onBack } : IDevtoolsProps ) : JSX . Element {
30
68
const { room } = useContext ( DevtoolsContext ) ;
31
69
const cli = useContext ( MatrixClientContext ) ;
@@ -90,13 +128,7 @@ export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Eleme
90
128
</ li >
91
129
{ roomHasUnread ( room ) && (
92
130
< >
93
- < li >
94
- { _t ( "User read up to: " ) }
95
- < strong >
96
- { room . getReadReceiptForUserId ( cli . getSafeUserId ( ) ) ?. eventId ??
97
- _t ( "No receipt found" ) }
98
- </ strong >
99
- </ li >
131
+ < UserReadUpTo target = { room } />
100
132
< li >
101
133
{ _t ( "Last event:" ) }
102
134
< ul >
@@ -149,13 +181,7 @@ export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Eleme
149
181
< li >
150
182
{ _t ( "Dot: " ) } < strong > { doesRoomOrThreadHaveUnreadMessages ( thread ) + "" } </ strong >
151
183
</ li >
152
- < li >
153
- { _t ( "User read up to: " ) }
154
- < strong >
155
- { thread . getReadReceiptForUserId ( cli . getSafeUserId ( ) ) ?. eventId ??
156
- _t ( "No receipt found" ) }
157
- </ strong >
158
- </ li >
184
+ < UserReadUpTo target = { thread } />
159
185
< li >
160
186
{ _t ( "Last event:" ) }
161
187
< ul >
0 commit comments