Page MenuHomePhabricator

[web] Fix message search results for old query appearing
ClosedPublic

Authored by inka on Jun 27 2023, 6:36 AM.
Tags
None
Referenced Files
F3372559: D8327.id28164.diff
Tue, Nov 26, 6:59 AM
F3367433: D8327.id28337.diff
Mon, Nov 25, 2:50 PM
Unknown Object (File)
Sat, Nov 23, 1:18 PM
Unknown Object (File)
Sat, Nov 23, 7:07 AM
Unknown Object (File)
Sat, Nov 23, 3:59 AM
Unknown Object (File)
Sat, Nov 23, 3:58 AM
Unknown Object (File)
Fri, Nov 22, 5:23 PM
Unknown Object (File)
Fri, Nov 22, 12:14 PM
Subscribers

Details

Summary

If the user searched for "first query", and then before the results had the chance to appear, search for "second query", the results for "first query" would still be appended to the results array.
This diff fixes that by using an id for each server call, and after the results get fetched, the id of the server call is compared with the most recent id.

Test Plan

Checked that flow is not broken in web and native that both use useSearchMessages. checked that the above scenario doesn't happen anymore (I used network dev tools to ensure the messages didn't get fetched before the query was changed). Checked that it is still possible to fetch messages, and more messages for the same query.

Diff Detail

Repository
rCOMM Comm
Branch
inka/search_web
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

inka edited the test plan for this revision. (Show Details)
inka requested review of this revision.Jun 27 2023, 6:57 AM
web/search/message-search-state-provider.react.js
117
127

I'm confused about this line. Shouldn't we wait until the most recent query completes before setting this? It appears we are letting eg. query 4 set loading to false before query 5 completes

lib/shared/search-utils.js
233

Why is this parameter optional? Is there any callsite that doesn't pass it in? If you want to allow undefined / null, it would be better to make the parameter required, but have it take ?number

236

Same feedback as above

web/search/message-search-state-provider.react.js
124

Same feedback as above

Instead of using another variable, could we pass query to appendResults and check if it's still the same?

queryID was optional in useSearchMessages, because useSearchMessages is used on native which didn't use the queryID, but it actually should

Instead of using another variable, could we pass query to appendResults and check if it's still the same?

No, because someone might:

  • query for 'a', wait to see results (server call no 1), scroll down and start fetching the second page of results for 'a' (server call no 2)
  • query for 'b' (server call no 3)
  • query for 'a' (server call no 4)

then they would see results for server call 2, so the second page of the results for 'a', instead of the first page

This revision is now accepted and ready to land.Jun 30 2023, 5:37 AM