diff options
-rw-r--r-- | poezio/mam.py | 11 | ||||
-rw-r--r-- | poezio/tabs/basetabs.py | 8 |
2 files changed, 11 insertions, 8 deletions
diff --git a/poezio/mam.py b/poezio/mam.py index a63b7b5f..7d34901e 100644 --- a/poezio/mam.py +++ b/poezio/mam.py @@ -52,6 +52,8 @@ async def query(self, remote_jid, start, end, top): for msg in rsm['mam']['results']: msgs.append(msg) if msg_count == 10: + timestamp = datetime.now() + add_line(text_buffer, 'End of MAM query: ', timestamp, 'MAM', top) return msg_count += 1 msgs.reverse() @@ -87,4 +89,11 @@ def mam_scroll(self): start = start + timedelta(days=-10) start = datetime.strftime(start, '%Y-%m-%dT%H:%M:%SZ') top = True - asyncio.ensure_future(query(self, remote_jid, start, end, top))
\ No newline at end of file + pos = self.text_win.pos + self.text_win.pos += self.text_win.height - 1 + if self.text_win.pos + self.text_win.height > len(self.text_win.built_lines): + asyncio.ensure_future(query(self, remote_jid, start, end, top)) + self.text_win.pos = len(self.text_win.built_lines) - self.text_win.height + if self.text_win.pos < 0: + self.text_win.pos = 0 + return self.text_win.pos != pos diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py index 30a35fa8..f23b3fd9 100644 --- a/poezio/tabs/basetabs.py +++ b/poezio/tabs/basetabs.py @@ -959,13 +959,7 @@ class ChatTab(Tab): return self.text_win.scroll_down(1) def on_scroll_up(self): - self.text_win.pos += self.text_win.height - 1 - pos = len(self.text_win.built_lines) - self.text_win.height - self.text_win.pos - if pos < 0: - mam.mam_scroll(self) - self.text_win.pos = 0 - else: - return self.text_win.scroll_up(self.text_win.height - 1) + return mam.mam_scroll(self) def on_scroll_down(self): return self.text_win.scroll_down(self.text_win.height - 1) |