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)
Tue, Jul 2, 9:02 AM
Unknown Object (File)
Mon, Jul 1, 1:12 AM
Unknown Object (File)
Mon, Jul 1, 12:10 AM
Unknown Object (File)
Sun, Jun 30, 5:21 PM
Unknown Object (File)
Sun, Jun 30, 1:20 PM
Unknown Object (File)
Wed, Jun 12, 8:39 PM
Unknown Object (File)
Jun 3 2024, 11:21 AM
Unknown Object (File)
May 27 2024, 12:30 PM

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