Page MenuHomePhabricator

[lib] Displaying edited content in a pending thread
ClosedPublic

Authored by kuba on Mar 22 2023, 5:52 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Mar 31, 6:59 AM
Unknown Object (File)
Thu, Mar 28, 6:46 AM
Unknown Object (File)
Wed, Mar 27, 10:24 PM
Unknown Object (File)
Wed, Mar 27, 10:11 PM
Unknown Object (File)
Mar 15 2024, 9:52 AM
Unknown Object (File)
Mar 15 2024, 9:51 AM
Unknown Object (File)
Mar 8 2024, 1:37 AM
Unknown Object (File)
Mar 7 2024, 1:44 PM
Subscribers

Details

Summary

When the user wants to create a thread from an edited message, we want him to see the updated content of the message.

Test Plan
  • [web & iOS] edited a message, clicked on it to create a sidebar from it, I can see updated content,
  • [web] on the pending thread route refreshed site, checked how it behaves: it just redirects to the main thread.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

lib/selectors/chat-selectors.js
622–623 ↗(On Diff #23988)

These two can be combined to reduce one array pass. Note that the callback you pass to useSelector will be executed any time any data in Redux changes, so it's a good idea to prioritize performance here

(Flow needs the Boolean pass to be separate however)

626 ↗(On Diff #23988)

This isn't exactly identical, but I think it works here

kuba marked 2 inline comments as done.

Address comments

lib/selectors/chat-selectors.js
624–625 ↗(On Diff #24060)

Personally I think this condition is more clear if you start by checking message.type, since most message types don't have message.targetMessageID

kuba marked an inline comment as done.

Removed 'Edited' label from the pending thread to match D7141 changes

Removed accidentally added empty line

lib/selectors/chat-selectors.js
606–628 ↗(On Diff #24267)

This is a very expensive calculation, since you go through every single message in the MessageStore for this thread

As mentioned above:

Note that the callback you pass to useSelector will be executed any time any data in Redux changes

I think it would be good here to pull this out of the useSelector, and put it in a useMemo below. That way, if the underlying data (containingThread.messageIDs?) doesn't change, then the calculation will not have to be run again

I'm not sure this is possible in this case, but I suspect it is. Can you think of a good useMemo we can pull out of this?

lib/selectors/chat-selectors.js
606–628 ↗(On Diff #24267)
ashoat requested changes to this revision.Mar 30 2023, 4:43 AM

"Add useMemo" isn't a good follow-up task, please respond to the diff comments here directly

This revision now requires changes to proceed.Mar 30 2023, 4:43 AM

Moved editedText to useMemo

ashoat added inline comments.
lib/selectors/chat-selectors.js
598 ↗(On Diff #24386)

In the codebase we typically do import * as React from 'react'; and then do React.useMemo here

This revision is now accepted and ready to land.Mar 30 2023, 2:56 PM
kuba marked an inline comment as done.

Changed useMemo usage