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
F3404703: D4357.id13785.diff
Tue, Dec 3, 12:37 PM
F3404350: D4357.diff
Tue, Dec 3, 8:34 AM
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

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