summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadhur Garg <madhurgarg96@gmail.com>2019-07-09 14:28:44 +0530
committerMadhur Garg <madhurgarg96@gmail.com>2019-08-22 00:54:25 +0530
commit6bd012e1292d78165f281b141fd7f755e239f0c1 (patch)
tree895c294bc197bf9ea6880ab871ec4e32c39c4bca
parent8e07c6d60e785fe15023800a942a0132a551b37a (diff)
downloadpoezio-6bd012e1292d78165f281b141fd7f755e239f0c1.tar.gz
poezio-6bd012e1292d78165f281b141fd7f755e239f0c1.tar.bz2
poezio-6bd012e1292d78165f281b141fd7f755e239f0c1.tar.xz
poezio-6bd012e1292d78165f281b141fd7f755e239f0c1.zip
Fixed scroll up
-rw-r--r--poezio/mam.py11
-rw-r--r--poezio/tabs/basetabs.py8
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)