-
-
Notifications
You must be signed in to change notification settings - Fork 655
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
Prevent fetching topics list if we already have them #4351
Conversation
Thanks, @shaurya2612! I think there might be a slightly simpler way to fix this, one that doesn't involve storing something in state. Would it work if we fetched unconditionally (for stream narrows anyway) at the start, probably in |
@chrisbobbe thanks for your perusal Working on it now! |
@chrisbobbe I omitted the state variable and achieved the same functionality with Thanks a lot ! |
Great, thanks, @shaurya2612! I've had a few more thoughts after looking a bit closer. It occurred to me that, without frequently re-fetching the topics, the list of topics might get to be unhelpfully out-of-date. New messages that come into the stream might have topics we haven't seen before, and we'll want those to show up in the list. Thankfully, I found that this is already handled. The list of topics mentioned in #2750 is rendered in the So, we just need to be sure that So, when a new message with a potentially new topic is received, the list of topics will indeed be kept up-to-date, and One thing I also noticed in the above investigation is that the code that's fetching the topics, in Also, I think we don't actually need to re-fetch the topics when the stream changes; i.e., the [1] I saw that the [2] There's a small wrinkle in |
Also, please be sure to run Also, I think everything should be squashable into a single commit, which would be good to do in keeping with our commit discipline. We have a handy guide for revising your local branch ("rewriting history" for the PR branch, so you don't need to make a new PR) here. 🙂 |
Thanks @chrisbobbe ! |
Before this, we were fetching the list of topics to populate TopicAutocomplete more frequently than necessary; in particular, we were doing so every time the topic input in `ComposeBox` was focused. The following should be sufficient to ensure we're up-to-date with the complete list of topics at all times that we need to be: - When we first expect to see the list, fetch all topics for the stream. - Afterwards, update the list when a new message arrives, if it introduces a new topic. The latter is already taken care of (see handling of EVENT_NEW_MESSAGE in topicsReducer). So, do the former -- and do it in `TopicAutocomplete`, which is much closer to where we consume the data. (ComposeBox is getting pretty crowded already.) See discussion [1]. [1] #4351 (comment) Co-authored-by: Chris Bobbe <cbobbe@zulip.com> Fixes: #2750
Thanks, @shaurya2612! Merged, with a few tweaks to the commit message; please take a look 🙂 (and see our doc on our preferred commit-message style):
I also expanded on the code comment you added, so there's more context on the important fact you mention (that "state.topics is updated on EVENT_NEW_MESSAGE actions"). ( And I added some quick TODOs from the discovery in #4351 (comment):
) |
Fixes : #2750
The Problem - Topics list was fetched for the current stream each time the TextInput was focussed, irrespective of if we have fetched the data before or not. Take a look at #2750 for more...
Video of the problem -
https://user-images.githubusercontent.com/36705866/102719650-2e97b300-4315-11eb-90d4-c6a4a15fcb39.mov
Fix - Now we fetch data only once for a specific stream. The query is made each time we move to a different stream
After fixing-
https://user-images.githubusercontent.com/36705866/102719838-68b58480-4316-11eb-90f1-b5e7b3a45f78.mov