diff --git a/frontends/src/primitivus/chat.py b/frontends/src/primitivus/chat.py index 75dd9e6f..c7ee46d3 100644 --- a/frontends/src/primitivus/chat.py +++ b/frontends/src/primitivus/chat.py @@ -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