[web] Fix warnings on search screen
Summary:
issue: https://linear.app/comm/issue/ENG-4897/[web]-warnings-in-message-search-modal
when I did the following:
- Search for a word
- Scroll down
- Clear the search query
I was seeing warnings on the console:
socket sent error data isn't of type T erverError: data isn't of type T at InflightRequests.resolveRequestsForMessage (inflight-requests.js:142:139) at WebSocket.eval (socket.react.js:170:24)
This was because when the query was cleared queries.current[threadID] was undefined, instead of an empty string. So code in useSearchMessages didn't handle it correctly. This is fixed by this diff, as getQuery returns
queries.current[threadID] ?? ''. useSearchMessages then decieds not to call the server, but return right away.
Test Plan: checked that in the scenario decribed in the summary the error does not appear. Checked that it is possible to fetch messages, and loda more by scrollng down.
Reviewers: ginsu, rohan, michal, atul
Reviewed By: michal
Subscribers: ashoat, tomek
Differential Revision: https://phab.comm.dev/D9123