channels: don't snap window to bottom of chat when a message arrives

This commit is contained in:
Jeremy O'Brien 2026-05-15 20:40:48 -04:00 • committed by Mark Qvist
parent 7e904ede5f
commit 087261c8bb

View file

@ -492,12 +492,14 @@ class RoomWidget(urwid.WidgetWrap):
widget = _message_widget(self.app, self.hub, msg, link_delegate=self.link_delegate) widget = _message_widget(self.app, self.hub, msg, link_delegate=self.link_delegate)
wrapped = urwid.AttrMap(widget, None) wrapped = urwid.AttrMap(widget, None)
body = self.messagelist._listbox.body body = self.messagelist._listbox.body
was_at_bottom = getattr(self, "_empty_placeholder", False) or getattr(self.messagelist, "bottom_is_visible", True)
if getattr(self, "_empty_placeholder", False): if getattr(self, "_empty_placeholder", False):
del body[:] del body[:]
self._empty_placeholder = False self._empty_placeholder = False
body.append(wrapped) body.append(wrapped)
while len(body) > self.MAX_RENDERED_MESSAGES: while len(body) > self.MAX_RENDERED_MESSAGES:
del body[0] del body[0]
if was_at_bottom:
try: try:
self.messagelist._listbox.set_focus(len(body)-1) self.messagelist._listbox.set_focus(len(body)-1)
self.messagelist._listbox.set_focus_valign("bottom") self.messagelist._listbox.set_focus_valign("bottom")