Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debounce to fetch results when conditions change #1149

Merged
merged 2 commits into from
Feb 23, 2024

Conversation

marySalvi
Copy link
Collaborator

@marySalvi marySalvi commented Feb 22, 2024

Closes #1034
Adding a debouce to fetchResults when conditions change ensures that the desired query when copying a url is fired second and eliminates the race condition.

@marySalvi marySalvi requested a review from naglepuff February 22, 2024 16:11
Copy link
Collaborator

@naglepuff naglepuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still seeing 2 requests on reload. (http://localhost:8081/?q=ChsIABACGAIiEyJNZXRhdHJhbnNjcmlwdG9tZSIKHwgAEAAYASIXIktFR0cuT1JUSE9MT0dZOkswMDI5MiI=)

This is likely because the fetchResults call on line 59 (outside of the watcher) is not debounced.

I think creating a debounced version of fetchResults and using it in both places would do the trick.

@marySalvi marySalvi requested a review from naglepuff February 23, 2024 20:42
@marySalvi
Copy link
Collaborator Author

I'm still seeing 2 requests on reload. (http://localhost:8081/?q=ChsIABACGAIiEyJNZXRhdHJhbnNjcmlwdG9tZSIKHwgAEAAYASIXIktFR0cuT1JUSE9MT0dZOkswMDI5MiI=)

This is likely because the fetchResults call on line 59 (outside of the watcher) is not debounced.

I think creating a debounced version of fetchResults and using it in both places would do the trick.

Good call. Fixed in e1d41fa

Copy link
Collaborator

@naglepuff naglepuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I used the network tab in devtools to verify that only:

  • 1 call was made to /api/biosample/search
  • 2 calls were made to /api/study/search (1 for studies, 1 for consortia),

Where before 2 and 4 calls were made respectively.

I also checked http://localhost:8081/users and http://localhost:8081/submission/home to make sure that the results weren't suppressed (which was the reason the original fix for this problem had to be rolled back).

@marySalvi marySalvi merged commit 492f894 into main Feb 23, 2024
2 checks passed
@marySalvi marySalvi deleted the 1034-url-query-fix branch February 23, 2024 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue when copying a data portal URL query from one google chrome tab to another
2 participants