diff options
author | mathieui <mathieui@mathieui.net> | 2020-05-22 01:55:32 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2020-05-23 16:10:13 +0200 |
commit | 36c85a5df4fc4650956bc3aa9d4e8474268a06a9 (patch) | |
tree | c15ae33a8fd745fda0e0ea70bb8bc25948985e93 /poezio/mam.py | |
parent | d174e1fa352dd5b8c479a71123ab25a7371dd5bd (diff) | |
download | poezio-36c85a5df4fc4650956bc3aa9d4e8474268a06a9.tar.gz poezio-36c85a5df4fc4650956bc3aa9d4e8474268a06a9.tar.bz2 poezio-36c85a5df4fc4650956bc3aa9d4e8474268a06a9.tar.xz poezio-36c85a5df4fc4650956bc3aa9d4e8474268a06a9.zip |
Add an "end of archive" message type
Diffstat (limited to 'poezio/mam.py')
-rw-r--r-- | poezio/mam.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/poezio/mam.py b/poezio/mam.py index 05275975..6882ef7a 100644 --- a/poezio/mam.py +++ b/poezio/mam.py @@ -26,7 +26,11 @@ from poezio import tabs from poezio import xhtml, colors from poezio.config import config from poezio.text_buffer import TextBuffer, HistoryGap -from poezio.ui.types import BaseMessage, Message +from poezio.ui.types import ( + BaseMessage, + EndOfArchive, + Message, +) log = logging.getLogger(__name__) @@ -270,6 +274,13 @@ async def on_scroll_up(tab) -> None: # (InfoTab changes height depending on the type of messages, see # `information_buffer_popup_on`). messages = await fetch_history(tab, amount=height) + if tab._text_buffer.messages: + last_message = tab._text_buffer.messages[0] + else: + last_message = None + if not messages and not isinstance(last_message, EndOfArchive): + time = tab._text_buffer.messages[0].time + messages = [EndOfArchive('End of archive reached', time=time)] tab._text_buffer.add_history_messages(messages) except NoMAMSupportException: tab.core.information('MAM not supported for %r' % tab.jid, 'Info') |