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, Dec 22, 6:49 AM
Unknown Object (File)
Sat, Dec 14, 7:02 AM
Unknown Object (File)
Fri, Dec 13, 6:11 PM
Unknown Object (File)
Tue, Dec 10, 12:04 AM
Unknown Object (File)
Sat, Dec 7, 11:38 PM
Unknown Object (File)
Fri, Dec 6, 9:51 PM
Unknown Object (File)
Thu, Dec 5, 1:56 AM
Unknown Object (File)
Thu, Dec 5, 1:56 AM
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