From 8b9ec4c4b284151390a493295ad92ab6f4b8e124 Mon Sep 17 00:00:00 2001 From: redshiftzero Date: Wed, 5 Jun 2019 16:22:12 -0700 Subject: [PATCH] app: ensure replies persist in conv view when switching sources two changes: 1. We should mark replies that we send as downloaded/decrypted so that we don't keep redownloading them. 2. We should refresh the source so that we get all items from the collection when we redraw it. --- securedrop_client/api_jobs/uploads.py | 4 +++- securedrop_client/gui/widgets.py | 2 +- securedrop_client/logic.py | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/securedrop_client/api_jobs/uploads.py b/securedrop_client/api_jobs/uploads.py index 0589ba680..765cfe7e6 100644 --- a/securedrop_client/api_jobs/uploads.py +++ b/securedrop_client/api_jobs/uploads.py @@ -48,10 +48,12 @@ def call_api(self, api_client: API, session: Session) -> str: source_id=source.id, journalist_id=api_client.token_journalist_uuid, filename=sdk_reply.filename, + content=self.message, + is_downloaded=True, + is_decrypted=True ) session.add(reply_db_object) session.commit() - return reply_db_object.uuid def _make_call(self, encrypted_reply: str, api_client: API) -> sdclientapi.Reply: diff --git a/securedrop_client/gui/widgets.py b/securedrop_client/gui/widgets.py index cc8fb656e..474ff32b3 100644 --- a/securedrop_client/gui/widgets.py +++ b/securedrop_client/gui/widgets.py @@ -1390,9 +1390,9 @@ def clear_conversation(self): def update_conversation(self, collection: list) -> None: # clear all old items self.clear_conversation() + self.controller.session.refresh(self.source) # add new items for conversation_item in collection: - self.controller.session.refresh(conversation_item) if conversation_item.filename.endswith('msg.gpg'): self.add_message(conversation_item) elif conversation_item.filename.endswith('reply.gpg'): diff --git a/securedrop_client/logic.py b/securedrop_client/logic.py index 13f82737d..a88b15bc8 100644 --- a/securedrop_client/logic.py +++ b/securedrop_client/logic.py @@ -595,9 +595,11 @@ def send_reply(self, source_uuid: str, reply_uuid: str, message: str) -> None: self.api_job_queue.enqueue(job) def on_reply_success(self, reply_uuid: str) -> None: + logger.debug('Reply send success: {}'.format(reply_uuid)) self.reply_succeeded.emit(reply_uuid) def on_reply_failure(self, reply_uuid: str) -> None: + logger.debug('Reply send failure: {}'.format(reply_uuid)) self.reply_failed.emit(reply_uuid) def get_file(self, file_uuid: str) -> db.File: