Skip to content

Commit

Permalink
refresh session whenever a reply succeeds
Browse files Browse the repository at this point in the history
  • Loading branch information
Allie Crevier committed Jul 24, 2019
1 parent c15426b commit 8952d13
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,12 @@ def __init__(
self.setLayout(main_layout)
self.update_conversation(self.source.collection)

# Refresh the session to update any replies that failed from a network timeout
self.controller.reply_succeeded.connect(self.refresh_conversation)

def refresh_conversation(self):
self.controller.session.refresh(self.source)

def clear_conversation(self):
while self.conversation_layout.count():
child = self.conversation_layout.takeAt(0)
Expand Down
13 changes: 13 additions & 0 deletions tests/gui/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,19 @@ def test_ConversationView_init(mocker, homedir):
assert isinstance(cv.conversation_layout, QVBoxLayout)


def test_ConversationView_refresh_conversation(mocker, homedir):
"""
Ensure that the session refreshes whenever there is a new reply in case there are previously
failed replies.
"""
source = factory.Source()
cv = ConversationView(source, mocker.MagicMock())

cv.refresh_conversation()

cv.controller.session.refresh.assert_called_with(source)


def test_ConversationView_update_conversation_position_follow(mocker, homedir):
"""
Check the signal handler sets the correct value for the scrollbar to be
Expand Down

0 comments on commit 8952d13

Please sign in to comment.