HomePhabricator
Diffusion Comm 8a334ca7bcda

[lib] Avoid creation new ChatThreadItem unnecessarily in…

Description

[lib] Avoid creation new ChatThreadItem unnecessarily in getSearchResultsForEmptySearchText

Summary:
In the process of investigating ENG-5674, I noticed an issue here. I had implemented a caching layer for useFlattenedChatListData so that it would avoid creating a new ChatThreadItem when the underlying data for it had not changed in Redux. But the code here was recreating the ChatThreadItem on every render anyways, forcing a bunch of components to rerender (and values to be recalculated) unnecessarily.

While I don't have a good long-term solution for ENG-5674 (and I probably won't prioritize it anytime soon), I think it's always best to avoid constructing new objects when the existing object suffices.

Test Plan: Flow

Reviewers: tomek, angelika

Reviewed By: tomek

Differential Revision: https://phab.comm.dev/D13903

Details