diff options
-rw-r--r-- | poezio/core/core.py | 2 | ||||
-rw-r--r-- | poezio/mam.py | 21 | ||||
-rw-r--r-- | poezio/tabs/basetabs.py | 2 | ||||
-rw-r--r-- | poezio/tabs/muctab.py | 2 |
4 files changed, 15 insertions, 12 deletions
diff --git a/poezio/core/core.py b/poezio/core/core.py index b67ace6a..c4ed3ac9 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -2009,7 +2009,7 @@ class Core: passwd=bm.password, status=self.status.message, show=self.status.show) - mam.mam_scroll(tab) + mam.mam_scroll(tab, action='query') def check_bookmark_storage(self, features): private = 'jabber:iq:private' in features diff --git a/poezio/mam.py b/poezio/mam.py index 2dfa251d..514c7b60 100644 --- a/poezio/mam.py +++ b/poezio/mam.py @@ -62,13 +62,13 @@ def add_line(tab, text_buffer: TextBuffer, text: str, str_time: str, nick: str, jid=None, ) -async def query(tab, remote_jid, top, start=None, end=None, before=None): +async def query(tab, remote_jid, action, top, start=None, end=None, before=None): text_buffer = tab._text_buffer try: iq = await tab.core.xmpp.plugin['xep_0030'].get_info(jid=remote_jid) except (IqError, IqTimeout): return tab.core.information('Failed to retrieve messages', 'Error') - if 'urn:xmpp:mam:2' not in iq['disco_info'].get_features(): + if 'urn:xmpp:mam:2' not in iq['disco_info'].get_features() and action is 'scroll': return tab.core.information("%s doesn't support MAM." % remote_jid, "Info") if top: if isinstance(tab, tabs.MucTab): @@ -80,7 +80,8 @@ async def query(tab, remote_jid, top, start=None, end=None, before=None): results = tab.core.xmpp['xep_0313'].retrieve(jid=remote_jid, iterator=True, reverse=top, end=end) except (IqError, IqTimeout): - return tab.core.information('Failed to retrieve messages', 'Error') + if action is 'scroll': + return tab.core.information('Failed to retrieve messages', 'Error') else: try: if before is not None: @@ -90,7 +91,8 @@ async def query(tab, remote_jid, top, start=None, end=None, before=None): results = tab.core.xmpp['xep_0313'].retrieve(with_jid=remote_jid, iterator=True, reverse=top, end=end) except (IqError, IqTimeout): - return tab.core.information('Failed to retrieve messages', 'Error') + if action is 'scroll': + return tab.core.information('Failed to retrieve messages', 'Error') else: if 'conference' in list(iq['disco_info']['identities'])[0]: try: @@ -125,7 +127,8 @@ async def query(tab, remote_jid, top, start=None, end=None, before=None): tab.last_stanza_id = msg['mam_result']['id'] nick = str(message['from']) add_line(tab, text_buffer, message['body'], timestamp, nick, top) - tab.text_win.scroll_up(len(tab.text_win.built_lines)) + if action is 'scroll': + tab.text_win.scroll_up(len(tab.text_win.built_lines)) else: for msg in rsm['mam']['results']: forwarded = msg['mam_result']['forwarded'] @@ -134,11 +137,11 @@ async def query(tab, remote_jid, top, start=None, end=None, before=None): nick = str(message['from']) add_line(tab, text_buffer, message['body'], timestamp, nick, top) tab.core.refresh_window() - if len(msgs) == 0: + if len(msgs) == 0 and action is 'scroll': return tab.core.information('No more messages left to retrieve', 'Info') tab.query_status = False -def mam_scroll(tab): +def mam_scroll(tab, action): remote_jid = tab.jid text_buffer = tab._text_buffer before = tab.last_stanza_id @@ -157,9 +160,9 @@ def mam_scroll(tab): tab.text_win.pos += tab.text_win.height - 1 if tab.text_win.pos + tab.text_win.height > len(tab.text_win.built_lines): if before is None: - asyncio.ensure_future(query(tab, remote_jid, top=True, end=end)) + asyncio.ensure_future(query(tab, remote_jid, action, top=True, end=end)) else: - asyncio.ensure_future(query(tab, remote_jid, top=True, before=before)) + asyncio.ensure_future(query(tab, remote_jid, action, top=True, before=before)) tab.query_status = True tab.text_win.pos = len(tab.text_win.built_lines) - tab.text_win.height if tab.text_win.pos < 0: diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py index f2da8469..22601ec7 100644 --- a/poezio/tabs/basetabs.py +++ b/poezio/tabs/basetabs.py @@ -919,7 +919,7 @@ class ChatTab(Tab): if self.query_status: return self.text_win.scroll_up(self.text_win.height - 1) else: - return mam.mam_scroll(tab=self) + return mam.mam_scroll(tab=self, action='scroll') def on_scroll_down(self): return self.text_win.scroll_down(self.text_win.height - 1) diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py index 2e810612..22e86705 100644 --- a/poezio/tabs/muctab.py +++ b/poezio/tabs/muctab.py @@ -157,7 +157,7 @@ class MucTab(ChatTab): status=status.message, show=status.show, seconds=seconds) - mam.mam_scroll(self) + mam.mam_scroll(self, action='query') def leave_room(self, message: str): if self.joined: |