Textbuffer: add "find last message" function
This commit is contained in:
parent
fbec652efd
commit
54339ee7e0
2 changed files with 8 additions and 1 deletions
|
@ -161,7 +161,7 @@ class MucTab(ChatTab):
|
|||
delta = datetime.now() - self.last_connection
|
||||
seconds = delta.seconds + delta.days * 24 * 3600
|
||||
else:
|
||||
seconds = None
|
||||
seconds = self._text_buffer.find_last_message()
|
||||
muc.join_groupchat(
|
||||
self.core,
|
||||
self.jid.bare,
|
||||
|
|
|
@ -277,6 +277,13 @@ class TextBuffer:
|
|||
def del_window(self, win) -> None:
|
||||
self._windows.remove(win)
|
||||
|
||||
def find_last_message(self) -> Optional[Message]:
|
||||
"""Find the last real message received in this buffer"""
|
||||
for message in reversed(self.messages):
|
||||
if isinstance(message, Message):
|
||||
return message
|
||||
return None
|
||||
|
||||
def __del__(self):
|
||||
size = len(self.messages)
|
||||
log.debug('** Deleting %s messages from textbuffer', size)
|
||||
|
|
Loading…
Reference in a new issue