From 9319911a27adeb8a503db379808251ae009e47c5 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 26 Jul 2023 11:18:43 +0100 Subject: [PATCH] Improve notifications debug devtool (#11310) --- .../dialogs/devtools/RoomNotifications.tsx | 54 ++++++++++++++----- src/i18n/strings/en_EN.json | 7 ++- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/src/components/views/dialogs/devtools/RoomNotifications.tsx b/src/components/views/dialogs/devtools/RoomNotifications.tsx index 25f4110ec1..6aed9125d5 100644 --- a/src/components/views/dialogs/devtools/RoomNotifications.tsx +++ b/src/components/views/dialogs/devtools/RoomNotifications.tsx @@ -17,6 +17,8 @@ limitations under the License. import { NotificationCountType, Room } from "matrix-js-sdk/src/models/room"; import { Thread } from "matrix-js-sdk/src/models/thread"; import React, { useContext } from "react"; +import { ReceiptType } from "matrix-js-sdk/src/@types/read_receipts"; +import { ReadReceipt } from "matrix-js-sdk/src/models/read-receipt"; import MatrixClientContext from "../../../../contexts/MatrixClientContext"; import { useNotificationState } from "../../../../hooks/useRoomNotificationState"; @@ -26,6 +28,42 @@ import { humanReadableNotificationColor } from "../../../../stores/notifications import { doesRoomOrThreadHaveUnreadMessages } from "../../../../Unread"; import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool"; +function UserReadUpTo({ target }: { target: ReadReceipt }): JSX.Element { + const cli = useContext(MatrixClientContext); + const userId = cli.getSafeUserId(); + const hasPrivate = !!target.getReadReceiptForUserId(userId, false, ReceiptType.ReadPrivate); + return ( + <> +
  • + {_t("User read up to: ")} + {target.getReadReceiptForUserId(userId)?.eventId ?? _t("No receipt found")} +
  • +
  • + {_t("User read up to (ignoreSynthetic): ")} + {target.getReadReceiptForUserId(userId, true)?.eventId ?? _t("No receipt found")} +
  • + {hasPrivate && ( + <> +
  • + {_t("User read up to (m.read.private): ")} + + {target.getReadReceiptForUserId(userId, false, ReceiptType.ReadPrivate)?.eventId ?? + _t("No receipt found")} + +
  • +
  • + {_t("User read up to (m.read.private;ignoreSynthetic): ")} + + {target.getReadReceiptForUserId(userId, true, ReceiptType.ReadPrivate)?.eventId ?? + _t("No receipt found")} + +
  • + + )} + + ); +} + export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Element { const { room } = useContext(DevtoolsContext); const cli = useContext(MatrixClientContext); @@ -90,13 +128,7 @@ export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Eleme {roomHasUnread(room) && ( <> -
  • - {_t("User read up to: ")} - - {room.getReadReceiptForUserId(cli.getSafeUserId())?.eventId ?? - _t("No receipt found")} - -
  • +
  • {_t("Last event:")}
      @@ -149,13 +181,7 @@ export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Eleme
    • {_t("Dot: ")} {doesRoomOrThreadHaveUnreadMessages(thread) + ""}
    • -
    • - {_t("User read up to: ")} - - {thread.getReadReceiptForUserId(cli.getSafeUserId())?.eventId ?? - _t("No receipt found")} - -
    • +
    • {_t("Last event:")}
        diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 5d2c0184d0..13bcc82fab 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -3210,6 +3210,11 @@ "Event Content": "Event Content", "Filter results": "Filter results", "No results found": "No results found", + "User read up to: ": "User read up to: ", + "No receipt found": "No receipt found", + "User read up to (ignoreSynthetic): ": "User read up to (ignoreSynthetic): ", + "User read up to (m.read.private): ": "User read up to (m.read.private): ", + "User read up to (m.read.private;ignoreSynthetic): ": "User read up to (m.read.private;ignoreSynthetic): ", "Room status": "Room status", "Room unread status: %(status)s, count: %(count)s|other": "Room unread status: %(status)s, count: %(count)s", "Room unread status: %(status)s, count: %(count)s|zero": "Room unread status: %(status)s", @@ -3220,8 +3225,6 @@ "Total: ": "Total: ", "Highlight: ": "Highlight: ", "Dot: ": "Dot: ", - "User read up to: ": "User read up to: ", - "No receipt found": "No receipt found", "Last event:": "Last event:", "ID: ": "ID: ", "Type: ": "Type: ",