Skip to content

Commit

Permalink
Fixed freedomofpress#61 and supercedes freedomofpress#685
Browse files Browse the repository at this point in the history
  • Loading branch information
ntoll committed Jan 29, 2020
1 parent 7a9f8a1 commit 5cbca48
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2419,6 +2419,9 @@ def __init__(self, source_db_object: Source, controller: Controller):
self.scroll.setWidget(self.container)
self.scroll.setWidgetResizable(True)

# Flag to show if the current user has sent a reply. See issue #61.
self.reply_flag = False

# Completely unintuitive way to ensure the view remains scrolled to the bottom.
sb = self.scroll.verticalScrollBar()
sb.rangeChanged.connect(self.update_conversation_position)
Expand Down Expand Up @@ -2490,11 +2493,9 @@ def update_conversation_position(self, min_val, max_val):
Handler called when a new item is added to the conversation. Ensures
it's scrolled to the bottom and thus visible.
"""
current_val = self.scroll.verticalScrollBar().value()
viewport_height = self.scroll.viewport().height()

if current_val + viewport_height > max_val:
if self.reply_flag and max_val > 0:
self.scroll.verticalScrollBar().setValue(max_val)
self.reply_flag = False

def add_message(self, message: Message, index) -> None:
"""
Expand Down Expand Up @@ -2544,6 +2545,7 @@ def on_reply_sent(self, source_uuid: str, reply_uuid: str, reply_text: str) -> N
"""
Add the reply text sent from ReplyBoxWidget to the conversation.
"""
self.reply_flag = True
# TODO: replace this with UI indication that the reply is "in flight"
# For now, just do nothing.
# if source_uuid == self.source.uuid:
Expand Down

0 comments on commit 5cbca48

Please sign in to comment.