HomePhabricator
Diffusion Comm f4471a9a2717

[keyserver/lib] Update rawMessageInfoForRowsAndRelatedMessages to check for…

Description

[keyserver/lib] Update rawMessageInfoForRowsAndRelatedMessages to check for canBeRenderedOnItsOwn

Summary:
As mentioned in D9536, we can now simplify the check in rawMessageInfoForRowsAndRelatedMessages to only filter out what is needed (EDIT_MESSAGE and REACTION). To do this, we'll call isUnableToBeRenderedOnItsOwn, which will check the message type's messageSpec, and then return the corresponding flag. This isolates the single source of truth to the individual message specs.

There is a usage of FlowFixMe here. I'll copy my explanation for using it here in the code as well so it's closer to it's usage, but essentially: Flow doesn't realize that only certain message types have the flag set as false, so we never get the type refinement we're expecting to set the rawMessageInfo into the map. The continue will ensure we don't set an invalid type into the map anyways, but once again Flow doesn't realize that. The only workaround I found was to basically invariant against every message type we don't expect to see (i.e. REACTION and EDIT_MESSAGE), but I want to avoid that since that 1) removes the 'single source of truth' that we've been working to achieve with this stack, and 2) makes it easier for future changes to this code to forget to update this invariant and then something will inevitably go wrong.

Resolves https://linear.app/comm/issue/ENG-5217/update-rawmessageinfoforrowsandrelatedmessages-to-check-for

Depends on D9536

Test Plan:
Ran yarn workspace lib test, and then opened Comm and saw no crashing. Tried to simulate normal behavior so I:

  • Logged back out and logged back in
  • Pinned some messages and opened the pinned messages modal
  • Unpinned some messages
  • Edited some messages before unpinning them and opening the pinned messages modal
  • Searching for messages in chats

Reviewers: atul, ginsu

Reviewed By: atul

Subscribers: ashoat, tomek, wyilio

Differential Revision: https://phab.comm.dev/D9537