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

bugfix: Update stream-setting checkboxes from subscription events. #981

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zee-bit
Copy link
Member

@zee-bit zee-bit commented Apr 5, 2021

This PR fixes the mismatch between stream settings if the StreamInfo popup is opened in ZT and subscription events are received from the server. The current approach registers a callback when the StreamInfoView is opened and looks for subscription events to trigger the callback, which in turn updates the checkbox UI.

Fixes #747.

@zulipbot zulipbot added size: M [Automatic label added by zulipbot] feedback wanted further discussion required Discuss this on #zulip-terminal on chat.zulip.org labels Apr 5, 2021
@neiljp
Copy link
Collaborator

neiljp commented Apr 5, 2021

I'm wary from the description that a polling approach is the way to go with this, but rather that we do something like register a callback when opening the popup, which is triggered on events. That could be the starting point for a shift in how we glue parts of the application together, including loosening the coupling between the model and UI.

@zee-bit zee-bit force-pushed the bugfix-checkbox-update-from-events branch from dec5b36 to 4fc75a7 Compare April 12, 2021 21:25
@zee-bit
Copy link
Member Author

zee-bit commented Apr 19, 2021

I have changed my approach from polling to callback-based. This works well as a v1, but I need some feedback on improvement so that I can generalize this for other UI elements that depend on events for updation.

  • The first commit just adds an asynch function that will be responsible for updating the checkbox UI and will be passed as callback.
  • The second commit defines the logic for registering and processing callbacks from model that will eventually be used to update the UI.

zee-bit added 2 commits June 3, 2021 00:55
This commit adds a function in StreamInfoView that runs asynchronously
at regular interval checking and updating the checkboxes. The function
is not yet executed from the StreamInfo view, because it doesnt yet
have the logic to stop the asynch function.
This commit adds two new functions in model.py:
- register_callback(): That registers callbacks for UI
elements and stores them in model.callbacks data-structure.
- process_callback(): That processes the corresponding callback
that are already registered after getting triggered from events.

These combined allow us to dynamically update the checkboxes in
stream_info popup after receiving events.

Fixes zulip#747.
@zee-bit zee-bit force-pushed the bugfix-checkbox-update-from-events branch from 4fc75a7 to b2defda Compare June 2, 2021 19:26
@zee-bit zee-bit added the PR needs review PR requires feedback to proceed label Jun 10, 2021
zee-bit added a commit to zee-bit/zulip-terminal that referenced this pull request Jul 5, 2021
This commit adds a new checkbox 'Visual desktop notification' in the
Stream settings section inside StreamInfoView. It uses model's
visual_notified_streams to get the initial state of the checkbox and
henceforth events to sync the "desktop notifications" data between
ZT <-> server.

The checkboxes are not updated dynamically after events but the
underlying data structure gets updated, hence re-opening the StreamInfo
view will display the correct state. We have a WIP PR zulip#981 that deals
with updating these checkboxes dynamically while the popup is still open.

Tests amended.

Fixes zulip#887.
zee-bit added a commit to zee-bit/zulip-terminal that referenced this pull request Jul 10, 2021
This commit adds a new checkbox 'Visual desktop notification' in the
Stream settings section inside StreamInfoView. It uses model's
visual_notified_streams to get the initial state of the checkbox and
henceforth events to sync the "desktop notifications" data between
ZT <-> server.

The checkboxes are not updated dynamically after events but the
underlying data structure gets updated, hence re-opening the StreamInfo
view will display the correct state. We have a WIP PR zulip#981 that deals
with updating these checkboxes dynamically while the popup is still open.

Tests amended.

Fixes zulip#887.
@zee-bit zee-bit changed the title [WIP] bugfix: Update stream-setting checkboxes from subscription events. bugfix: Update stream-setting checkboxes from subscription events. Jul 10, 2021
neiljp pushed a commit to neiljp/zulip-terminal that referenced this pull request Jul 13, 2021
This commit adds a new checkbox 'Visual desktop notification' in the
Stream settings section inside StreamInfoView. It uses model's
visual_notified_streams to get the initial state of the checkbox and
henceforth events to sync the "desktop notifications" data between
ZT <-> server.

The checkboxes are not updated dynamically after events but the
underlying data structure gets updated, hence re-opening the StreamInfo
view will display the correct state. We have a WIP PR zulip#981 that deals
with updating these checkboxes dynamically while the popup is still open.

Tests amended.

Fixes zulip#887.
neiljp pushed a commit to neiljp/zulip-terminal that referenced this pull request Jul 13, 2021
This commit adds a new checkbox 'Visual desktop notification' in the
Stream settings section inside StreamInfoView. It uses model's
visual_notified_streams to get the initial state of the checkbox and
henceforth events to sync the "desktop notifications" data between
ZT <-> server.

The checkboxes are not updated dynamically after events but the
underlying data structure gets updated, hence re-opening the StreamInfo
view will display the correct state. We have a WIP PR zulip#981 that deals
with updating these checkboxes dynamically while the popup is still open.

Tests amended.

Fixes zulip#887.
neiljp pushed a commit to zee-bit/zulip-terminal that referenced this pull request Jul 13, 2021
This commit adds a new checkbox 'Visual desktop notification' in the
Stream settings section inside StreamInfoView. It uses model's
visual_notified_streams to get the initial state of the checkbox and
henceforth events to sync the "desktop notifications" data between
ZT <-> server.

The checkboxes are not updated dynamically after events but the
underlying data structure gets updated, hence re-opening the StreamInfo
view will display the correct state. We have a WIP PR zulip#981 that deals
with updating these checkboxes dynamically while the popup is still open.

Tests amended.

Fixes zulip#887.
neiljp pushed a commit that referenced this pull request Jul 13, 2021
This commit adds a new checkbox 'Visual desktop notification' in the
Stream settings section inside StreamInfoView. It uses model's
visual_notified_streams to get the initial state of the checkbox and
henceforth events to sync the "desktop notifications" data between
ZT <-> server.

The checkboxes are not updated dynamically after events but the
underlying data structure gets updated, hence re-opening the StreamInfo
view will display the correct state. We have a WIP PR #981 that deals
with updating these checkboxes dynamically while the popup is still open.

Tests amended.

Fixes #887.
@zulipbot
Copy link
Member

Heads up @zee-bit, 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/main branch and resolve your pull request's merge conflicts accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: event handling How events from the server are responded to area: popup: stream feedback wanted further discussion required Discuss this on #zulip-terminal on chat.zulip.org has conflicts PR needs review PR requires feedback to proceed size: M [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update stream settings pop-up on receiving subscription events
3 participants