-
-
Notifications
You must be signed in to change notification settings - Fork 278
model: Notify user if a request fails. #714
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
model: Notify user if a request fails. #714
Conversation
@kaustubh-nair This looks fairly straightforward as you mentioned. 👍 One suggestion maybe (not sure if we already had a discussion of this) whether we can display these kinds of error messages in a different way than regular help tips ones. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaustubh-nair This is definitely beneficial in terms of alerting the user to issues and so far nicely simple, if repetitive.
Have you tested this? How?
Does the same issue happen here as in another PR, namely if we get lots of failures, the repeated footer updates lead to subsequent rapid help tip updates?
There may be scope to include the server registration aspects too - these can fail too!
While we do have controller/view calls from the model already, I'm a little wary of having so many calls to controller methods in the model - the alternative is to update the calling points to update the view themselves, based on the return values which we already have in many cases.
zulipterminal/model.py
Outdated
if response['result'] == 'error': | ||
self.controller.view.set_footer_text(response['msg'], 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the apparent similarity in all this error handling, please use a new method for this.
Putting this in a function should make testing simple?
@neiljp thanks for the review. |
ab56996
to
0240e28
Compare
@kaustubh-nair I agree that if initial data does not exist then we cannot easily show an error message in the UI, though we could extend the startup error handling via exceptions for that case. If we do already have initial data then we can notify of connection failure, which could occur in the same method, but possibly more in |
Opened #716 |
Controller.client is already mocked for all tests in a pytest fixture.
0240e28
to
e9b352d
Compare
Move the return value patch for client.update_subscription_status to a default argument, so that it can be used again later.
This commit displays an error message in the footer for server requests involving user interactions. By this the user can be notified for different failures like: * Hitting API rate limits. * Posting in streams where user doesn't have the required permissions. * Message sending/editing errors. * Toggling reaction errors. * etc. Error responses from some requests are not displayed, since they are not triggered directly by a user action. Example of these include event polling requests, event registration, and updating presence. Tests added. Fixes zulip#427.
e9b352d
to
f1e98f5
Compare
@@ -535,11 +535,10 @@ def test_fail_get_messages(self, mocker, error_response, | |||
], ids=['muting_205', 'unmuting_205', 'first_muted_205', | |||
'last_unmuted_205']) | |||
def test_toggle_stream_muted_status(self, mocker, model, | |||
initial_muted_streams, value): | |||
initial_muted_streams, value, | |||
response={'result': 'success'}): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this to overcome pytest's caching issue or just to reuse the dict
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for reuse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaustubh-nair These changes look good now.
One aspect which @neiljp mentioned as well, is if there was a way to manually test this?
@sumanthvrao @neiljp, I haven't tested every single one of these, but some of them can be tested like
|
@kaustubh-nair As per PMs, I just merged the last two commits together - thanks for working on this! 🎉 Time to update the release notes again 👍 |
This commit displays an error message in the footer for server requests
involving user interactions. By this the user can be notified for
different failures like:
Error responses from some requests are not displayed, since they are not
triggered directly by a user action. Example of these include event
polling requests, event registration, and updating presence.
Fixes #427.