From 9381fe24626a9bf5c4f958ab44e1852ed6907f4b Mon Sep 17 00:00:00 2001 From: Allie Crevier Date: Wed, 3 Apr 2019 15:25:50 -0700 Subject: [PATCH] undo changes to adding a reply to the gui --- securedrop_client/gui/widgets.py | 19 +++++++++---------- tests/gui/test_widgets.py | 4 ++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/securedrop_client/gui/widgets.py b/securedrop_client/gui/widgets.py index d4823f3eb..be2ab8834 100644 --- a/securedrop_client/gui/widgets.py +++ b/securedrop_client/gui/widgets.py @@ -27,7 +27,7 @@ from typing import List from uuid import uuid4 -from securedrop_client.db import Source, Message, File, Reply +from securedrop_client.db import Source, Message, File from securedrop_client.logic import Client from securedrop_client.resources import load_svg, load_image from securedrop_client.utils import humanize_filesize @@ -807,7 +807,12 @@ def update_conversation(self, collection: list) -> None: if conversation_item.filename.endswith('msg.gpg'): self.add_message(conversation_item) elif conversation_item.filename.endswith('reply.gpg'): - self.add_reply(conversation_item) + self.controller.session.refresh(conversation_item) + if conversation_item.content is not None: + content = conversation_item.content + else: + content = '' + self.add_reply(conversation_item.uuid, content) else: self.add_file(self.source, conversation_item) @@ -843,18 +848,12 @@ def add_message(self, message: Message) -> None: self.conversation_layout.addWidget( MessageWidget(message.uuid, content, self.controller.message_sync.message_ready)) - def add_reply(self, reply: Reply) -> None: + def add_reply(self, uuid: str, content: str) -> None: """ Add a reply from a journalist. """ - self.controller.session.refresh(reply) - if reply.content is not None: - content = reply.content - else: - content = '' - self.conversation_layout.addWidget( - ReplyWidget(reply.uuid, + ReplyWidget(uuid, content, self.controller.reply_sync.reply_ready, self.controller.reply_succeeded, diff --git a/tests/gui/test_widgets.py b/tests/gui/test_widgets.py index b419fcd14..dc9234937 100644 --- a/tests/gui/test_widgets.py +++ b/tests/gui/test_widgets.py @@ -976,7 +976,7 @@ def test_ConversationView_add_reply(mocker, homedir, session, source): mock_reply_widget = mocker.patch('securedrop_client.gui.widgets.ReplyWidget', return_value=mock_reply_widget_res) - cv.add_reply(reply) + cv.add_reply(reply.uuid, content) # check that we built the widget was called with the correct args mock_reply_widget.assert_called_once_with( @@ -1019,7 +1019,7 @@ def test_ConversationView_add_reply_no_content(mocker, homedir, session, source) mock_reply_widget = mocker.patch('securedrop_client.gui.widgets.ReplyWidget', return_value=mock_reply_widget_res) - cv.add_reply(reply) + cv.add_reply(reply.uuid, '') # check that we built the widget was called with the correct args mock_reply_widget.assert_called_once_with(