Commit 2ca14edb authored by Madhur Garg's avatar Madhur Garg

Fixed repeated query for messages on pressing PageUp

parent 241f026c
......@@ -57,6 +57,7 @@ async def query(self, remote_jid, start, end, top):
for msg in rsm['mam']['results']:
msgs.append(msg)
if msg_count == 10:
self.query_id = 0
timestamp = datetime.now()
add_line(text_buffer, 'End of MAM query: ', timestamp, 'MAM', top)
self.core.refresh_window()
......@@ -76,6 +77,7 @@ async def query(self, remote_jid, start, end, top):
message = forwarded['stanza']
add_line(text_buffer, message['body'], timestamp, str(message['from']), top)
self.core.refresh_window()
self.query_id = 0
timestamp = datetime.now()
add_line(text_buffer, 'End of MAM query: ', timestamp, 'MAM', top)
......@@ -101,6 +103,7 @@ def mam_scroll(self):
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.query_id = 1
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
......
......@@ -474,6 +474,7 @@ class ChatTab(Tab):
jid = JID(jid)
assert jid.domain
self._jid = jid
self.query_id = 0
self._name = jid.full # type: Optional[str]
self.text_win = None
......@@ -959,7 +960,10 @@ class ChatTab(Tab):
return self.text_win.scroll_down(1)
def on_scroll_up(self):
return mam.mam_scroll(self)
if self.query_id == 0:
return mam.mam_scroll(self)
else:
return self.text_win.scroll_up(self.text_win.height - 1)
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