views: Preserve focus and search on external pin events#1633
Open
maciej103 wants to merge 2 commits intozulip:mainfrom
Open
views: Preserve focus and search on external pin events#1633maciej103 wants to merge 2 commits intozulip:mainfrom
maciej103 wants to merge 2 commits intozulip:mainfrom
Conversation
bcec1fd to
6e33d37
Compare
Previously, search_lock was set after super().__init__(), which meant an external pinning event could trigger the @Asynch update_streams before search_lock existed, causing an AttributeError (see zulip#1487).
6e33d37 to
4464764
Compare
313d96e to
3ec673d
Compare
When a pin/unpin event arrived from an external client, update_stream_view() rebuilt StreamsView from scratch, resetting focus to the top and clearing any active search. Save and restore the focus index and search text around the rebuild. Clamp the focus index in case the list shrank after a pin event. Fixes zulip#1487.
3ec673d to
8c65828
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do, and why?
When a stream pin/unpin event arrives from an external client,
update_stream_view() rebuilt StreamsView from scratch. This reset
focus to the top of the list and cleared any active search. If a
pin event occurred while the search box was active, it also caused
an AttributeError due to search_lock not yet being initialized.
This fixes the bugs in #1487 by saving and restoring focus position
and search text around the rebuild, and by moving search_lock
initialization earlier in StreamsView.init().
External discussion & connections
How did you test this?
Self-review checklist for each commit