Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 9319911

Browse files
authored
Improve notifications debug devtool (#11310)
1 parent e33a7e4 commit 9319911

File tree

2 files changed

+45
-16
lines changed

2 files changed

+45
-16
lines changed

src/components/views/dialogs/devtools/RoomNotifications.tsx

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
import { NotificationCountType, Room } from "matrix-js-sdk/src/models/room";
1818
import { Thread } from "matrix-js-sdk/src/models/thread";
1919
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";
2022

2123
import MatrixClientContext from "../../../../contexts/MatrixClientContext";
2224
import { useNotificationState } from "../../../../hooks/useRoomNotificationState";
@@ -26,6 +28,42 @@ import { humanReadableNotificationColor } from "../../../../stores/notifications
2628
import { doesRoomOrThreadHaveUnreadMessages } from "../../../../Unread";
2729
import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool";
2830

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+
2967
export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Element {
3068
const { room } = useContext(DevtoolsContext);
3169
const cli = useContext(MatrixClientContext);
@@ -90,13 +128,7 @@ export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Eleme
90128
</li>
91129
{roomHasUnread(room) && (
92130
<>
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} />
100132
<li>
101133
{_t("Last event:")}
102134
<ul>
@@ -149,13 +181,7 @@ export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Eleme
149181
<li>
150182
{_t("Dot: ")} <strong>{doesRoomOrThreadHaveUnreadMessages(thread) + ""}</strong>
151183
</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} />
159185
<li>
160186
{_t("Last event:")}
161187
<ul>

src/i18n/strings/en_EN.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3210,6 +3210,11 @@
32103210
"Event Content": "Event Content",
32113211
"Filter results": "Filter results",
32123212
"No results found": "No results found",
3213+
"User read up to: ": "User read up to: ",
3214+
"No receipt found": "No receipt found",
3215+
"User read up to (ignoreSynthetic): ": "User read up to (ignoreSynthetic): ",
3216+
"User read up to (m.read.private): ": "User read up to (m.read.private): ",
3217+
"User read up to (m.read.private;ignoreSynthetic): ": "User read up to (m.read.private;ignoreSynthetic): ",
32133218
"Room status": "Room status",
32143219
"Room unread status: <strong>%(status)s</strong>, count: <strong>%(count)s</strong>|other": "Room unread status: <strong>%(status)s</strong>, count: <strong>%(count)s</strong>",
32153220
"Room unread status: <strong>%(status)s</strong>, count: <strong>%(count)s</strong>|zero": "Room unread status: <strong>%(status)s</strong>",
@@ -3220,8 +3225,6 @@
32203225
"Total: ": "Total: ",
32213226
"Highlight: ": "Highlight: ",
32223227
"Dot: ": "Dot: ",
3223-
"User read up to: ": "User read up to: ",
3224-
"No receipt found": "No receipt found",
32253228
"Last event:": "Last event:",
32263229
"ID: ": "ID: ",
32273230
"Type: ": "Type: ",

0 commit comments

Comments
 (0)