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

When pinning or unpinning messages, link to the specific message #6489

Merged
merged 11 commits into from
Sep 3, 2021
Merged

When pinning or unpinning messages, link to the specific message #6489

merged 11 commits into from
Sep 3, 2021

Conversation

psrpinto
Copy link
Contributor

Fixes element-hq/element-web#17947

This PR makes it so that, whenever a single message is pinned or unpinned, a link to the message is supplied. Whenever more than one message is pinned/unpinned, it falls back to the previous behavior: Foo changed the pinned messages for the room.

Screenshot 2021-07-27 at 17 28 30

@t3chguy t3chguy requested a review from a team July 27, 2021 16:37
@psrpinto
Copy link
Contributor Author

psrpinto commented Jul 27, 2021

I'm not super happy with the code here since there's a lot of repetition happening and the textForPinnedEvent() function is getting out of hand. I think, maybe in a follow-up PR, this could be extracted to a component (though I'm not sure where that component would go).

I think another subject to consider would be the need for the allowJSX parameter, which introduces significant complexity. After chatting with @SimonBrandner, this parameter is needed since Notifications can only contain plain text. I think maybe we could look into generating the plain text from the JSX/HTML? I think that could be feasible, and would remove the need for the allowJSX parameter, and also the translations for the plain text versions.

Finally, something else to consider is that there's some shared concerns between the code in the textForPinnedEvent() function and the MemberEventListSummary, as evidenced in #6349. I think this maybe shows the need for a component, as I mention above, though it's maybe too early to consider those shared concerns.

Signed-off-by: Paulo Pinto <[email protected]>
Signed-off-by: Paulo Pinto <[email protected]>
@turt2live
Copy link
Member

(if this is ready for review, please take it out of draft state - thanks!)

@psrpinto psrpinto marked this pull request as ready for review July 27, 2021 17:04
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall it looks great, just a couple points to cover!

src/TextForEvent.tsx Outdated Show resolved Hide resolved
src/TextForEvent.tsx Outdated Show resolved Hide resolved
test/TextForEvent-test.ts Outdated Show resolved Hide resolved
test/__snapshots__/TextForEvent-test.ts.snap Outdated Show resolved Hide resolved
@turt2live turt2live requested a review from a team August 5, 2021 21:34
So that there's one top level `describe('TextForEvent')`, followed by a nested
`describe('textForPinnedEvent')`, containting all the `it()`s.

Signed-off-by: Paulo Pinto <[email protected]>
@turt2live turt2live self-requested a review August 11, 2021 13:14
The test case is:
"mentions message when a single message was pinned, with multiple previously pinned messages"

However, the test case was also unpinning messages. That is now fixed.

Signed-off-by: Paulo Pinto <[email protected]>
Just moving test cases so that "generic message" ones are grouped at the bottom.

Signed-off-by: Paulo Pinto <[email protected]>
@psrpinto
Copy link
Contributor Author

I believe I've addressed all remarks, this should be ready for re-review 🙏

Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Here's hoping design gets to it soon 😅

@amshakal
Copy link

Designer is here to review and it looks good! 👯 👯

@turt2live turt2live merged commit 60e2d61 into matrix-org:develop Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Format pinned message changes to reflect the actual changes
4 participants