Skip to content

Commit

Permalink
fix(ReplyWidget): handle update_signal as successful reply
Browse files Browse the repository at this point in the history
Fixes a partition[1][2] between SpeechBubble._update_text(), called when
a reply has been downloaded from the Journalist API, and
ReplyWidget._on_reply_success(), called when a reply has been
successfully sent via the SDK.  In the case where the Client starts with
a reply still pending from a previous session and the reply is
subsequently downloaded, ReplyWidget.status will not be updated from
Reply.send_status unless it too listens for the SpeechBubble's
update_signal, and future calls to ReplyWidget._update_styles() will be
based on a stale ReplyWidget.status.

While conflating these signals is not ideal, in the current data model
we might as well, since a reply downloaded from the server is by
definition one that has been successfully sent to the server.  See
<#1493 (comment)>.

[1]: #1486 (review)
[2]: #1486 (comment)
  • Loading branch information
cfm committed Dec 8, 2022
1 parent 3333199 commit c405d1d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2037,6 +2037,7 @@ def __init__( # type: ignore [no-untyped-def]

self.check_mark.show()

update_signal.connect(self._on_reply_success)
message_succeeded_signal.connect(self._on_reply_success)
message_failed_signal.connect(self._on_reply_failure)
self.controller.update_authenticated_user.connect(self._on_update_authenticated_user)
Expand Down
1 change: 1 addition & 0 deletions tests/gui/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4518,6 +4518,7 @@ def test_ReplyWidget_success_failure_slots(mocker):
)

# ensure we have connected the slots
mock_update_signal.connect.assert_called_with(widget._on_reply_success)
mock_success_signal.connect.assert_called_once_with(widget._on_reply_success)
mock_failure_signal.connect.assert_called_once_with(widget._on_reply_failure)
assert mock_update_signal.connect.called # to ensure no stale mocks
Expand Down

0 comments on commit c405d1d

Please sign in to comment.