Page MenuHomePhabricator

[lib][native][web] Introduce EntityText
ClosedPublic

Authored by ashoat on Feb 1 2023, 2:03 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 14, 8:17 PM
Unknown Object (File)
Thu, Nov 14, 8:17 PM
Unknown Object (File)
Sat, Oct 26, 9:22 PM
Unknown Object (File)
Sat, Oct 26, 9:22 PM
Unknown Object (File)
Sat, Oct 26, 9:22 PM
Unknown Object (File)
Sat, Oct 26, 9:22 PM
Unknown Object (File)
Sat, Oct 26, 9:21 PM
Unknown Object (File)
Sat, Oct 26, 9:14 PM
Subscribers
None

Details

Summary

For the ENS work, we need to be able to "introspect" into robotext, find the usernames, and swap them out. This is much easier to do when have an AST to deal with instead of a string.

This will also allow us to get rid of global_viewer in favor of having the messageTitle code just go through the AST and set isViewer to false everywhere.

In future diffs I'll update notifTexts, messageTitle, and uiName (as well as robotext) to all use this new EntityText framework. We need to swap in ENS names in all of these cases.

Test Plan

There's a small unit test here, but mostly this has been tested in combination with the following diffs

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ashoat requested review of this revision.Feb 1 2023, 2:20 PM
lib/utils/entity-text.js
85 ↗(On Diff #21803)

I should return immediately here

Clean up getNameForThreadEntity

Looks complicated but correct. Reviewing this thoroughly might take more time, but I haven't found any issues yet.

lib/utils/entity-text.js
87 ↗(On Diff #21821)
142–144 ↗(On Diff #21821)

Can we use index instead?

native/chat/inner-robotext-message.react.js
51–63 ↗(On Diff #21821)

Maybe if we type the functions as components, we can simplify this code? I'm thinking about a solution where we can simply write renderThread: ThreadEntity.

This revision is now accepted and ready to land.Feb 2 2023, 6:10 AM
lib/utils/entity-text.js
87 ↗(On Diff #21821)

This won't work – Flow can't refine the type of entity unless the invariant is explicitly on entity

128 ↗(On Diff #21821)

This is joining with commas – it should've been passed an empty string

142–144 ↗(On Diff #21821)

Yeah, that's a way better idea

native/chat/inner-robotext-message.react.js
51–63 ↗(On Diff #21821)

The downsides are:

  1. We'd have to increase the depth of the component hierarchy
  2. We'd have to introduce a new component for renderText

I think the downsides outweigh the upsides personally... I don't see this change improving readability all that much

This revision was automatically updated to reflect the committed changes.