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

Fix conversation refresh bugs 467, 463 #481

Merged
merged 2 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,9 @@ def on_source_changed(self):
# else we create it.
try:
conversation_wrapper = self.source_conversations[source]

# Redraw the conversation view such that new messages, replies, files appear.
conversation_wrapper.conversation_view.update_conversation(source.collection)
except KeyError:
conversation_wrapper = SourceConversationWrapper(source, self.controller)
self.source_conversations[source] = conversation_wrapper
Expand Down
11 changes: 10 additions & 1 deletion tests/gui/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,8 @@ def test_MainView_on_source_changed_SourceConversationWrapper_is_preserved(mocke
session.commit()

source_conversation_init = mocker.patch(
'securedrop_client.gui.widgets.SourceConversationWrapper.__init__', return_value=None)
'securedrop_client.gui.widgets.SourceConversationWrapper.__init__',
return_value=None)

# We expect on the first call, SourceConversationWrapper.__init__ should be called.
mv.source_list.get_current_source = mocker.MagicMock(return_value=source)
Expand All @@ -516,8 +517,16 @@ def test_MainView_on_source_changed_SourceConversationWrapper_is_preserved(mocke
# But if we click back (call on_source_changed again) to the source,
# its SourceConversationWrapper should _not_ be recreated.
mv.source_list.get_current_source = mocker.MagicMock(return_value=source)
conversation_wrapper = mv.source_conversations[source]
conversation_wrapper.conversation_view = mocker.MagicMock()
conversation_wrapper.conversation_view.update_conversation = mocker.MagicMock()

mv.on_source_changed()

assert mv.set_conversation.call_count == 1

# Conversation should be redrawn even for existing source (bug #467).
assert conversation_wrapper.conversation_view.update_conversation.call_count == 1
assert source_conversation_init.call_count == 0


Expand Down