Commit aae00af2 authored by Madhur Garg's avatar Madhur Garg

Changed query_id from int to boolean type.

parent 47dc7f00
...@@ -67,7 +67,7 @@ async def query(tab, remote_jid, top, start=None, end=None, before=None): ...@@ -67,7 +67,7 @@ async def query(tab, remote_jid, top, start=None, end=None, before=None):
try: try:
iq = await tab.core.xmpp.plugin['xep_0030'].get_info(jid=remote_jid) iq = await tab.core.xmpp.plugin['xep_0030'].get_info(jid=remote_jid)
except (IqError, IqTimeout): except (IqError, IqTimeout):
return tab.information('Failed to retrieve messages', 'Error') return tab.core.information('Failed to retrieve messages', 'Error')
if 'urn:xmpp:mam:2' not in iq['disco_info'].get_features(): if 'urn:xmpp:mam:2' not in iq['disco_info'].get_features():
return tab.core.information("%s doesn't support MAM." % remote_jid, "Info") return tab.core.information("%s doesn't support MAM." % remote_jid, "Info")
if top: if top:
...@@ -113,7 +113,7 @@ async def query(tab, remote_jid, top, start=None, end=None, before=None): ...@@ -113,7 +113,7 @@ async def query(tab, remote_jid, top, start=None, end=None, before=None):
'{%s}%s' % ('jabber:client', 'body')) is not None: '{%s}%s' % ('jabber:client', 'body')) is not None:
msgs.append(msg) msgs.append(msg)
if msg_count == 10: if msg_count == 10:
tab.query_id = 0 tab.query_status = False
tab.core.refresh_window() tab.core.refresh_window()
return return
msg_count += 1 msg_count += 1
...@@ -136,7 +136,7 @@ async def query(tab, remote_jid, top, start=None, end=None, before=None): ...@@ -136,7 +136,7 @@ async def query(tab, remote_jid, top, start=None, end=None, before=None):
tab.core.refresh_window() tab.core.refresh_window()
if len(msgs) == 0: if len(msgs) == 0:
return tab.core.information('No more messages left to retrieve', 'Info') return tab.core.information('No more messages left to retrieve', 'Info')
tab.query_id = 0 tab.query_status = False
def mam_scroll(tab): def mam_scroll(tab):
remote_jid = tab.jid remote_jid = tab.jid
...@@ -160,7 +160,7 @@ def mam_scroll(tab): ...@@ -160,7 +160,7 @@ def mam_scroll(tab):
asyncio.ensure_future(query(tab, remote_jid, top=True, end=end)) asyncio.ensure_future(query(tab, remote_jid, top=True, end=end))
else: else:
asyncio.ensure_future(query(tab, remote_jid, top=True, before=before)) asyncio.ensure_future(query(tab, remote_jid, top=True, before=before))
tab.query_id = 1 tab.query_status = True
tab.text_win.pos = len(tab.text_win.built_lines) - tab.text_win.height tab.text_win.pos = len(tab.text_win.built_lines) - tab.text_win.height
if tab.text_win.pos < 0: if tab.text_win.pos < 0:
tab.text_win.pos = 0 tab.text_win.pos = 0
......
...@@ -474,7 +474,7 @@ class ChatTab(Tab): ...@@ -474,7 +474,7 @@ class ChatTab(Tab):
jid = JID(jid) jid = JID(jid)
assert jid.domain assert jid.domain
self._jid = jid self._jid = jid
self.query_id = 0 self.query_status = False
self.last_stanza_id = None self.last_stanza_id = None
self._name = jid.full # type: Optional[str] self._name = jid.full # type: Optional[str]
...@@ -928,10 +928,10 @@ class ChatTab(Tab): ...@@ -928,10 +928,10 @@ class ChatTab(Tab):
return self.text_win.scroll_down(1) return self.text_win.scroll_down(1)
def on_scroll_up(self): def on_scroll_up(self):
if self.query_id == 0: if self.query_status:
return mam.mam_scroll(tab=self)
else:
return self.text_win.scroll_up(self.text_win.height - 1) return self.text_win.scroll_up(self.text_win.height - 1)
else:
return mam.mam_scroll(tab=self)
def on_scroll_down(self): def on_scroll_down(self):
return self.text_win.scroll_down(self.text_win.height - 1) 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