diff options
author | mathieui <mathieui@mathieui.net> | 2021-04-11 20:48:53 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2021-04-11 20:48:53 +0200 |
commit | ee972599f01883ddf83705a4834188d4490dadfd (patch) | |
tree | 2eb49ac7a7141718399066adbc607e79d06c1288 | |
parent | 02a858eb49cdb6acd9082de539ebaf4bb4f773be (diff) | |
download | poezio-ee972599f01883ddf83705a4834188d4490dadfd.tar.gz poezio-ee972599f01883ddf83705a4834188d4490dadfd.tar.bz2 poezio-ee972599f01883ddf83705a4834188d4490dadfd.tar.xz poezio-ee972599f01883ddf83705a4834188d4490dadfd.zip |
fix: do not fetch ALL messages from logfiles when filling a gap
-rw-r--r-- | poezio/log_loader.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/poezio/log_loader.py b/poezio/log_loader.py index 1e1d80b9..d729bd91 100644 --- a/poezio/log_loader.py +++ b/poezio/log_loader.py @@ -41,6 +41,10 @@ from poezio.text_buffer import HistoryGap from slixmpp import JID +# Max number of messages to insert when filling a gap +HARD_LIMIT = 999 + + log = logging.getLogger(__name__) @@ -154,7 +158,12 @@ class LogLoader: if end: end = end - timedelta(seconds=1) try: - return await fetch_history(tab, start=start, end=end, amount=999) + return await fetch_history( + tab, + start=start, + end=end, + amount=HARD_LIMIT + ) except (NoMAMSupportException, MAMQueryException, DiscoInfoException): return [] finally: @@ -179,6 +188,8 @@ class LogLoader: break if typ_ == 'message' and (not end or msg['time'] < end): results.append(make_line_local(self.tab, msg)) + if len(results) >= HARD_LIMIT: + break return results[::-1] async def scroll_requested(self): |