Commit 6bd012e1 authored by Madhur Garg's avatar Madhur Garg

Fixed scroll up

parent 8e07c6d6
......@@ -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
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment