From e3c1ac4033b3f9f2888e494aa6ab459a2e4c52c2 Mon Sep 17 00:00:00 2001 From: Madhur Garg Date: Wed, 21 Aug 2019 02:55:21 +0530 Subject: [PATCH] Initialized stanza_id in the basetabs. --- poezio/mam.py | 25 +++++++++++-------------- poezio/tabs/basetabs.py | 1 + 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/poezio/mam.py b/poezio/mam.py index bcb31024..4c8f3309 100644 --- a/poezio/mam.py +++ b/poezio/mam.py @@ -141,21 +141,18 @@ async def query(tab, remote_jid, top, start=None, end=None, before=None): def mam_scroll(tab): remote_jid = tab.jid text_buffer = tab._text_buffer - try: - before = tab.stanza_id - except: - before = None - end = datetime.now() - if isinstance(tab, tabs.MucTab) is False: - for message in text_buffer.messages: - time = message.time - if time < end: - end = time + before = tab.stanza_id + end = datetime.now() + if isinstance(tab, tabs.MucTab) is False: + for message in text_buffer.messages: + time = message.time + if time < end: + end = time end = end + timedelta(seconds=-1) - tzone = datetime.now().astimezone().tzinfo - end = end.replace(tzinfo=tzone).astimezone(tz=timezone.utc) - end = end.replace(tzinfo=None) - end = datetime.strftime(end, '%Y-%m-%dT%H:%M:%SZ') + tzone = datetime.now().astimezone().tzinfo + end = end.replace(tzinfo=tzone).astimezone(tz=timezone.utc) + end = end.replace(tzinfo=None) + end = datetime.strftime(end, '%Y-%m-%dT%H:%M:%SZ') top = True pos = tab.text_win.pos tab.text_win.pos += tab.text_win.height - 1 diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py index 12fcd170..f61c3f76 100644 --- a/poezio/tabs/basetabs.py +++ b/poezio/tabs/basetabs.py @@ -475,6 +475,7 @@ class ChatTab(Tab): assert jid.domain self._jid = jid self.query_id = 0 + self.stanza_id = None self._name = jid.full # type: Optional[str] self.text_win = None