Skip to content

Commit

Permalink
Remove old way of checking deletion timestamp
Browse files Browse the repository at this point in the history
Signed-off-by: Allie Crevier <[email protected]>
  • Loading branch information
Allie Crevier committed Mar 15, 2022
1 parent c2d1344 commit 06a3102
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,11 +1357,6 @@ def set_snippet(
if self.deleting or self.deleting_conversation:
return

# If the sync started before the deletion finished, then the sync is stale and we do
# not want to update the source widget.
if self.sync_started_timestamp < self.deletion_scheduled_timestamp:
return

# If the source collection is empty yet the interaction_count is greater than zero, then we
# known that the conversation has been deleted.
if not self.source.server_collection:
Expand Down Expand Up @@ -2984,18 +2979,15 @@ def _on_conversation_deletion_successful(self, source_uuid: str, timestamp: date
logger.debug(f"Could not update ConversationView: {e}")

def update_deletion_markers(self) -> None:
try:
if self.source.collection:
self.scroll.show()
if self.source.collection[0].file_counter > 1:
self.deleted_conversation_marker.hide()
self.deleted_conversation_items_marker.show()
elif self.source.interaction_count > 0:
self.scroll.hide()
self.deleted_conversation_items_marker.hide()
self.deleted_conversation_marker.show()
except sqlalchemy.exc.InvalidRequestError as e:
logger.debug(f"Could not Update deletion markers in the ConversationView: {e}")
if self.source.collection:
self.scroll.show()
if self.source.collection[0].file_counter > 1:
self.deleted_conversation_marker.hide()
self.deleted_conversation_items_marker.show()
elif self.source.interaction_count > 0:
self.scroll.hide()
self.deleted_conversation_items_marker.hide()
self.deleted_conversation_marker.show()

def update_conversation(self, collection: list) -> None:
"""
Expand All @@ -3016,11 +3008,6 @@ def update_conversation(self, collection: list) -> None:
passed into this method in case of a mismatch between where the widget
has been and now is in terms of its index in the conversation.
"""
# If the sync started before the deletion finished, then the sync is stale and we do
# not want to update the conversation.
if self.sync_started_timestamp < self.deletion_scheduled_timestamp:
return

self.controller.session.refresh(self.source)

# Keep a temporary copy of the current conversation so we can delete any
Expand Down Expand Up @@ -3157,7 +3144,7 @@ def add_reply(self, reply: Union[DraftReply, Reply], sender: User, index: int) -
self.scroll.add_widget_to_conversation(index, conversation_item, Qt.AlignRight)
self.current_messages[reply.uuid] = conversation_item

def on_reply_sent(self, source_uuid: str, reply_uuid: str, reply_text: str) -> None:
def on_reply_sent(self, source_uuid: str) -> None:
"""
Add the reply text sent from ReplyBoxWidget to the conversation.
"""
Expand All @@ -3167,7 +3154,6 @@ def on_reply_sent(self, source_uuid: str, reply_uuid: str, reply_text: str) -> N
self.update_conversation(self.source.collection)
except sqlalchemy.exc.InvalidRequestError as e:
logger.debug(e)
self.update_deletion_markers()


class SourceConversationWrapper(QWidget):
Expand Down Expand Up @@ -3311,7 +3297,7 @@ class ReplyBoxWidget(QWidget):
A textbox where a journalist can enter a reply.
"""

reply_sent = pyqtSignal(str, str, str)
reply_sent = pyqtSignal(str)

def __init__(self, source: Source, controller: Controller) -> None:
super().__init__()
Expand Down Expand Up @@ -3408,7 +3394,7 @@ def send_reply(self) -> None:
self.text_edit.setText("")
reply_uuid = str(uuid4())
self.controller.send_reply(self.source.uuid, reply_uuid, reply_text)
self.reply_sent.emit(self.source.uuid, reply_uuid, reply_text)
self.reply_sent.emit(self.source.uuid)

@pyqtSlot(bool)
def _on_authentication_changed(self, authenticated: bool) -> None:
Expand Down

0 comments on commit 06a3102

Please sign in to comment.