From a399e59e463b3876f157caeb78f750c6fcd08947 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 13 Sep 2019 03:52:13 +0530 Subject: Corrected the functionality of query_status --- poezio/mam.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'poezio') diff --git a/poezio/mam.py b/poezio/mam.py index c42e7a18..ad1c07e2 100644 --- a/poezio/mam.py +++ b/poezio/mam.py @@ -191,6 +191,7 @@ async def fetch_history(tab, end: Optional[datetime] = None, amount: Optional[in async def on_tab_open(tab) -> None: amount = 2 * tab.text_win.height end = datetime.now() + tab.query_status = True for message in tab._text_buffer.messages: time = message.time if time < end: @@ -199,6 +200,7 @@ async def on_tab_open(tab) -> None: try: await fetch_history(tab, end=end, amount=amount) except (NoMAMSupportException, MAMQueryException, DiscoInfoException): + tab.query_status = False return None @@ -210,6 +212,10 @@ async def on_scroll_up(tab) -> None: # join if not already available. total, pos, height = len(tw.built_lines), tw.pos, tw.height rest = (total - pos) // height + # Not resetting the state of query_status here, it is changed only after the + # query is complete (in fetch_history) + # This is done to stop message repetition, eg: if the user presses PageUp continuously. + tab.query_status = True if rest > 1: return None -- cgit v1.2.3