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)
Sat, Oct 5, 2:41 AM
Unknown Object (File)
Thu, Sep 12, 11:47 AM
Unknown Object (File)
Thu, Sep 12, 11:47 AM
Unknown Object (File)
Thu, Sep 12, 11:47 AM
Unknown Object (File)
Thu, Sep 12, 11:45 AM
Unknown Object (File)
Sep 1 2024, 8:35 PM
Unknown Object (File)
Sep 1 2024, 8:03 PM
Unknown Object (File)
Aug 10 2024, 10:55 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
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

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