Skip to content

Commit

Permalink
app: ensure replies persist in conv view when switching sources
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
redshiftzero committed Jun 6, 2019
1 parent ea5b57b commit 8b9ec4c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion securedrop_client/api_jobs/uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down
2 changes: 2 additions & 0 deletions securedrop_client/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8b9ec4c

Please sign in to comment.