summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadhur Garg <madhurgarg96@gmail.com>2019-07-16 00:54:40 +0530
committerMadhur Garg <madhurgarg96@gmail.com>2019-08-22 00:54:25 +0530
commit2ca14edbb5fa27ad39f596e92e640a38e94ac4f8 (patch)
treedaec0f76ffb7495b0e1a848ef8571029156b723d
parent241f026ccfd46b946bd2386aff4453c219f7630e (diff)
downloadpoezio-2ca14edbb5fa27ad39f596e92e640a38e94ac4f8.tar.gz
poezio-2ca14edbb5fa27ad39f596e92e640a38e94ac4f8.tar.bz2
poezio-2ca14edbb5fa27ad39f596e92e640a38e94ac4f8.tar.xz
poezio-2ca14edbb5fa27ad39f596e92e640a38e94ac4f8.zip
Fixed repeated query for messages on pressing PageUp
-rw-r--r--poezio/mam.py3
-rw-r--r--poezio/tabs/basetabs.py6
2 files changed, 8 insertions, 1 deletions
diff --git a/poezio/mam.py b/poezio/mam.py
index a6cd05f6..7b22e5a1 100644
--- a/poezio/mam.py
+++ b/poezio/mam.py
@@ -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
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py
index f23b3fd9..ccd3a9d0 100644
--- a/poezio/tabs/basetabs.py
+++ b/poezio/tabs/basetabs.py
@@ -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)