Corrected the functionality of query_status
This commit is contained in:
parent
31751bcb61
commit
a399e59e46
1 changed files with 6 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue