mirror of
https://github.com/element-hq/element-web
synced 2024-11-22 17:25:50 +03:00
Handle case where one message is pinned, and another unpinned
Signed-off-by: Paulo Pinto <paulo.pinto@automattic.com>
This commit is contained in:
parent
a51b114171
commit
aaeb9969a4
2 changed files with 12 additions and 2 deletions
|
@ -435,7 +435,7 @@ function textForPinnedEvent(event: MatrixEvent, allowJSX: boolean): () => string
|
|||
const newlyPinned = pinned.filter(item => previouslyPinned.indexOf(item) < 0);
|
||||
const newlyUnpinned = previouslyPinned.filter(item => pinned.indexOf(item) < 0);
|
||||
|
||||
if (newlyPinned.length === 1) {
|
||||
if (newlyPinned.length === 1 && newlyUnpinned.length === 0) {
|
||||
// A single message was pinned, include a link to that message.
|
||||
if (allowJSX) {
|
||||
const messageId = newlyPinned.pop();
|
||||
|
@ -463,7 +463,7 @@ function textForPinnedEvent(event: MatrixEvent, allowJSX: boolean): () => string
|
|||
return () => _t("%(senderName)s pinned a message to this room. See all pinned messages.", { senderName });
|
||||
}
|
||||
|
||||
if (newlyUnpinned.length === 1) {
|
||||
if (newlyUnpinned.length === 1 && newlyPinned.length === 0) {
|
||||
// A single message was unpinned, include a link to that message.
|
||||
if (allowJSX) {
|
||||
const messageId = newlyUnpinned.pop();
|
||||
|
|
|
@ -115,5 +115,15 @@ describe('TextForEvent', () => {
|
|||
expect(plainText).toBe(expectedText);
|
||||
expect(renderComponent(component)).toBe(expectedText);
|
||||
});
|
||||
|
||||
it("shows generic text when one message was pinned, and another unpinned", () => {
|
||||
const event = mockPinnedEvent(['message-2'], ['message-1']);
|
||||
const plainText = textForEvent(event);
|
||||
const component = renderer.create(textForEvent(event, true));
|
||||
|
||||
const expectedText = "@foo:example.com changed the pinned messages for the room.";
|
||||
expect(plainText).toBe(expectedText);
|
||||
expect(renderComponent(component)).toBe(expectedText);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue