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

Refresh topic list view on update message events #785

Closed

Conversation

kaustubh-nair
Copy link
Member

No description provided.

@zulipbot zulipbot added the size: S [Automatic label added by zulipbot] label Aug 22, 2020
@kaustubh-nair kaustubh-nair marked this pull request as draft August 22, 2020 16:56
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@kaustubh-nair Thanks for looking into this - this will fix a bug, though I couldn't find an issue for it.

topic_view,
self.view.left_panel.options(height_type="weight")
)
self.view.left_panel.show_topics_view(self)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This appears to be the only current place where this code occurs, and while I know this is a refactoring aimed purely at the following commit, it would be useful to combine the extraction/encapsulation of this method with related ones. That could be anywhere we update the contents, which is anywhere near is_in_topic_view (which we could move to a renamed property, perhaps)

Copy link
Member Author

Choose a reason for hiding this comment

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

I've done this by making two methods, one each for updating topics view and stream view, and making minor tweaks in update_stream_view (previously update_structure). I hope this covers everything.

for msg_id in event['message_ids']:
self.index['messages'][msg_id]['subject'] = new_subject
self._update_rendered_view(msg_id)
if stream_id in self.index['topics']:
# Reload topic list.
self._fetch_topics_in_streams([stream_id])
Copy link
Collaborator

Choose a reason for hiding this comment

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

While this seems reasonable as a v0, don't these events allow us to reorder what we already have instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

@neiljp No, as I mentioned on czo, due to the topic data in the index never being complete, there is no way of knowing when a topic is empty (i.e doesn't have any messages left).

It would be useful if the backend response could include an extra flag when this happens, though it's not present currently AFAIK.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's discuss on #zulip-terminal.

@neiljp
Copy link
Collaborator

neiljp commented Sep 4, 2020

@kaustubh-nair I think we've clarified via czo that it's OK to use the topic fetch approach, though as I mentioned elsewhere it'd be useful if we didn't fetch it unless/until we actively need it (for the subsequent conditional, or possibly another state we may be in?). For example, if we were in a stream narrow and triggered a topic rename and not showing the topic list, we could wait until autocompleting topics or showing the topic narrow before fetching it?

You didn't respond regarding the first point for the refactoring, but we can chat on czo regarding this if you like.

@neiljp neiljp added the high priority should be done as soon as possible label Sep 7, 2020
@zulipbot zulipbot added size: L [Automatic label added by zulipbot] and removed size: S [Automatic label added by zulipbot] labels Sep 8, 2020
@zulipbot zulipbot added size: XL [Automatic label added by zulipbot] and removed size: L [Automatic label added by zulipbot] labels Sep 11, 2020
@kaustubh-nair kaustubh-nair added the PR needs review PR requires feedback to proceed label Sep 11, 2020
@kaustubh-nair kaustubh-nair marked this pull request as ready for review September 11, 2020 17:11
@kaustubh-nair
Copy link
Member Author

@neiljp Thanks for the review! I have made the topic fetch conditional, resetting the cache when not needed. I've also incorporated the refactor you mentioned (and a few others), if something has been left out in that let me know.

Tests fixed and added.

@neiljp
Copy link
Collaborator

neiljp commented Oct 17, 2020

@kaustubh-nair As per comment in the stream just now, I've just merged most of the early commits with minor text/layout changes. The topic is not being updated in some cases, so I'd like to debug that before merging.

@zulipbot
Copy link
Member

zulipbot commented Nov 3, 2020

Heads up @kaustubh-nair, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/master branch and resolve your pull request's merge conflicts accordingly.

This updates the topic list when it is open, else resets topic cache
if present.

Tests amended.
@neiljp neiljp closed this in #832 Nov 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feedback wanted has conflicts high priority should be done as soon as possible PR needs review PR requires feedback to proceed size: XL [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants