Page MenuHomePhabricator

[lib] Remove extraneous ternary from `threadUIName` in `thread-utils`
ClosedPublic

Authored by abosh on Jun 24 2022, 1:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 29, 10:48 PM
Unknown Object (File)
Mon, Nov 25, 9:50 AM
Unknown Object (File)
Sat, Nov 9, 11:40 AM
Unknown Object (File)
Sat, Nov 9, 11:40 AM
Unknown Object (File)
Fri, Nov 8, 8:08 AM
Unknown Object (File)
Tue, Nov 5, 2:02 AM
Unknown Object (File)
Oct 22 2024, 5:52 AM
Unknown Object (File)
Oct 21 2024, 6:43 AM

Details

Summary

This ternary's condition and expression if true are the same, so it can be replaced with an ||. Note that the cases still remain the same (the most notable being if threadInfo.name === '', then the expression if false is still chosen since '' is falsy).

Test Plan

Flow, close reading

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Note that the cases still remain the same (the most notable being if threadInfo.name === '', then the expression if false is still chosen since '' is falsy).

Thanks for clarifying this.

return firstLine(
  threadInfo.name ?? robotextName(threadInfo, viewerID, userInfos),
);

wouldn't work because it only cares if the LHS is null or undefined. But, both the ternary and || operator only care about "truthiness." And the empty string is "falsey," so this looks good!

This revision is now accepted and ready to land.Jun 24 2022, 3:32 PM