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 authored and sssoleileraaa committed Jul 24, 2019
1 parent 00e5dcc commit 4633946
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,13 @@ 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)
self.update_conversation(self.source.collection)

def clear_conversation(self):
while self.conversation_layout.count():
child = self.conversation_layout.takeAt(0)
Expand Down
15 changes: 15 additions & 0 deletions tests/gui/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,21 @@ 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())
mocker.patch.object(cv, 'update_conversation')

cv.refresh_conversation()

cv.controller.session.refresh.assert_called_with(source)
cv.update_conversation.assert_called_once_with(source.collection)


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 4633946

Please sign in to comment.