diff --git a/securedrop_client/logic.py b/securedrop_client/logic.py index 0229b323b..6b52325ff 100644 --- a/securedrop_client/logic.py +++ b/securedrop_client/logic.py @@ -752,8 +752,11 @@ def on_delete_source_success(self, result) -> None: """ Handler for when a source deletion succeeds. """ + # Delete the local version of the source. + storage.delete_local_source_by_uuid(self.session, result) self.gui.clear_error_status() # remove any permanent error status message - self.sync_api() + # Update the sources UI. + self.update_sources() def on_delete_source_failure(self, result: Exception) -> None: logging.info("failed to delete source at server") diff --git a/securedrop_client/storage.py b/securedrop_client/storage.py index 95aae3019..5bfe0c35f 100644 --- a/securedrop_client/storage.py +++ b/securedrop_client/storage.py @@ -47,6 +47,15 @@ def get_local_sources(session: Session) -> List[Source]: return session.query(Source).all() +def delete_local_source_by_uuid(session: Session, uuid: str) -> Source: + """ + Return the source with the referenced UUID. + """ + source = session.query(Source).filter_by(uuid=uuid) + session.delete(source) + session.commit() + + def get_local_messages(session: Session) -> List[Message]: """ Return all submission objects from the local database.