summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--poezio/tabs/muctab.py2
-rw-r--r--poezio/text_buffer.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py
index f5d1c700..7b0f8a42 100644
--- a/poezio/tabs/muctab.py
+++ b/poezio/tabs/muctab.py
@@ -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,
diff --git a/poezio/text_buffer.py b/poezio/text_buffer.py
index 121a797a..03ad2f1b 100644
--- a/poezio/text_buffer.py
+++ b/poezio/text_buffer.py
@@ -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)