Skip to content

Commit

Permalink
temporary fix for freedomofpress#144
Browse files Browse the repository at this point in the history
  • Loading branch information
deeplow committed Feb 18, 2019
1 parent 3414250 commit 847d08f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ def __init__(self, source_db_object: Source, sdc_home: str, controller: Client,
# Completely unintuitive way to ensure the view remains scrolled to the
# bottom.
sb = self.scroll.verticalScrollBar()
sb.rangeChanged.connect(self.move_to_bottom)
sb.rangeChanged.connect(self.update_conversation_position)

main_layout = QVBoxLayout()
main_layout.addWidget(self.scroll)
Expand Down Expand Up @@ -736,12 +736,16 @@ def add_file(self, source_db_object, submission_db_object):
FileWidget(source_db_object, submission_db_object,
self.controller))

def move_to_bottom(self, min_val, max_val):
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.
"""
self.scroll.verticalScrollBar().setValue(max_val)
current_val = self.scroll.verticalScrollBar().value()
viewport_height = self.scroll.viewport().height()

if current_val + viewport_height > max_val:
self.scroll.verticalScrollBar().setValue(max_val)

def add_message(self, message_id: str, message: str) -> None:
"""
Expand Down

0 comments on commit 847d08f

Please sign in to comment.