diff --git a/src/TextForEvent.tsx b/src/TextForEvent.tsx
index d85b7519ae64..06af7b4a97b1 100644
--- a/src/TextForEvent.tsx
+++ b/src/TextForEvent.tsx
@@ -615,10 +615,37 @@ function textForPinnedEvent(event: MatrixEvent, client: MatrixClient, allowJSX:
}
if (newlyUnpinned.length === 1 && newlyPinned.length === 0) {
+ const emptyPinned = pinned.length === 0;
+
// A single message was unpinned, include a link to that message.
if (allowJSX) {
const messageId = newlyUnpinned.pop()!;
+ // If there are no remaining pinned messages, don't show the link to all the pinned messages
+ if (emptyPinned) {
+ return () => (
+
+ {_t(
+ "timeline|m.room.pinned_events|unpinned_last_link",
+ { senderName },
+ {
+ a: (sub) => (
+ {
+ PosthogTrackers.trackInteraction("PinnedMessageStateEventClick");
+ highlightEvent(roomId, messageId);
+ }}
+ >
+ {sub}
+
+ ),
+ },
+ )}
+
+ );
+ }
+
return () => (
{_t(
@@ -647,7 +674,10 @@ function textForPinnedEvent(event: MatrixEvent, client: MatrixClient, allowJSX:
);
}
- return () => _t("timeline|m.room.pinned_events|unpinned", { senderName });
+ return () =>
+ emptyPinned
+ ? _t("timeline|m.room.pinned_events|unpinned_last", { senderName })
+ : _t("timeline|m.room.pinned_events|unpinned", { senderName });
}
if (allowJSX) {
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index e1e44efc61d5..e02b36e4d90e 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -3478,7 +3478,9 @@
"changed_link": "%(senderName)s changed the pinned messages for the room.",
"pinned": "%(senderName)s pinned a message to this room. See all pinned messages.",
"pinned_link": "%(senderName)s pinned a message to this room. See all pinned messages.",
+ "unpinned_last": "%(senderName)s unpinned a message from this room.",
"unpinned": "%(senderName)s unpinned a message from this room. See all pinned messages.",
+ "unpinned_last_link": "%(senderName)s unpinned a message from this room.",
"unpinned_link": "%(senderName)s unpinned a message from this room. See all pinned messages."
},
"m.room.power_levels": {
diff --git a/test/TextForEvent-test.ts b/test/TextForEvent-test.ts
index ce5c4a97f69c..9272349b2cf2 100644
--- a/test/TextForEvent-test.ts
+++ b/test/TextForEvent-test.ts
@@ -103,7 +103,7 @@ describe("TextForEvent", () => {
const plainText = textForEvent(event, mockClient);
const component = render(textForEvent(event, mockClient, true) as ReactElement);
- const expectedText = "@foo:example.com unpinned a message from this room. See all pinned messages.";
+ const expectedText = "@foo:example.com unpinned a message from this room.";
expect(plainText).toBe(expectedText);
expect(component.container).toHaveTextContent(expectedText);
});