primitivus(chat): fixed scroll down (was broken when Primitivus had not the focus and was receiving messages)
This commit is contained in:
parent
b4312f210a
commit
4dea715ec5
1 changed files with 10 additions and 5 deletions
|
|
@ -405,6 +405,14 @@ class Chat(PrimitivusWidget, quick_chat.QuickChat):
|
|||
else:
|
||||
return info_type in quick_chat.ROOM_USER_MOVED
|
||||
|
||||
def _scrollDown(self):
|
||||
"""scroll down message only if we are already at the bottom (minus 1)"""
|
||||
current_focus = self.mess_widgets.focus_position
|
||||
bottom = len(self.mess_walker) - 1
|
||||
if current_focus == bottom - 1:
|
||||
self.mess_widgets.focus_position = bottom # scroll down
|
||||
self.host.redraw() # FIXME: should not be necessary
|
||||
|
||||
def appendMessage(self, message):
|
||||
"""Create a MessageWidget and append it
|
||||
|
||||
|
|
@ -442,6 +450,7 @@ class Chat(PrimitivusWidget, quick_chat.QuickChat):
|
|||
self.focus_marker = urwid.Divider('—')
|
||||
self.mess_walker.append(self.focus_marker)
|
||||
self.focus_marker_set = True
|
||||
self._scrollDown()
|
||||
else:
|
||||
if self.focus_marker_set:
|
||||
self.focus_marker_set = False
|
||||
|
|
@ -451,11 +460,7 @@ class Chat(PrimitivusWidget, quick_chat.QuickChat):
|
|||
else:
|
||||
wid = MessageWidget(message)
|
||||
self.mess_walker.append(wid)
|
||||
current_focus = self.mess_widgets.focus_position
|
||||
bottom = len(self.mess_walker) - 1
|
||||
if current_focus == bottom - 1:
|
||||
self.mess_widgets.focus_position = bottom # scroll down
|
||||
self.host.redraw() # FIXME: should not be necessary
|
||||
self._scrollDown()
|
||||
if self._user_moved(message):
|
||||
return # no notification for moved messages
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue