diff options
-rw-r--r-- | doc/source/configuration.rst | 8 | ||||
-rw-r--r-- | poezio/config.py | 1 | ||||
-rw-r--r-- | poezio/log_loader.py | 7 | ||||
-rw-r--r-- | poezio/tabs/basetabs.py | 3 | ||||
-rw-r--r-- | poezio/tabs/muctab.py | 3 |
5 files changed, 17 insertions, 5 deletions
diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index f8d04296..56f546d8 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -868,6 +868,14 @@ Options related to logging. If ``true``, will try to fill local logs with missing MAM history when opening a tab or joining a room. + mam_sync_limit + + **Default value:** ``2000`` + + Maximum number of messages to fetch on a MAM sync. Will affect + performance when joining rooms with a huge backlog for the first time + or after a long period. + Plugins ~~~~~~~ diff --git a/poezio/config.py b/poezio/config.py index e98a57c1..1eda2e86 100644 --- a/poezio/config.py +++ b/poezio/config.py @@ -93,6 +93,7 @@ DEFAULT_CONFIG: ConfigDict = { 'log_dir': '', 'log_errors': True, 'mam_sync': True, + 'mam_sync_limit': 2000, 'max_lines_in_memory': 2048, 'max_messages_in_memory': 2048, 'max_nick_length': 25, diff --git a/poezio/log_loader.py b/poezio/log_loader.py index 835ea3da..edfaf90b 100644 --- a/poezio/log_loader.py +++ b/poezio/log_loader.py @@ -265,14 +265,15 @@ class MAMFiller: logger: Logger future: asyncio.Future done: asyncio.Event - max_msgs: int = 2000 + limit: int - def __init__(self, logger: Logger, tab: tabs.ChatTab): + def __init__(self, logger: Logger, tab: tabs.ChatTab, limit: int = 2000): self.tab = tab self.logger = logger logger.fd_busy(tab.jid) self.future = asyncio.ensure_future(self.fetch_routine()) self.done = asyncio.Event() + self.limit = limit def cancel(self) -> None: """Cancel the routine and signal the end.""" @@ -292,7 +293,7 @@ class MAMFiller: messages = await fetch_history( self.tab, start=last_msg_time, - amount=self.max_msgs, + amount=self.limit, ) log.debug( 'Fetched %s messages to fill local logs for %s', diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py index 34b2efdc..2046b866 100644 --- a/poezio/tabs/basetabs.py +++ b/poezio/tabs/basetabs.py @@ -1014,7 +1014,8 @@ class OneToOneTab(ChatTab): use_log = config.get_by_tabname('use_log', self.jid) mam_sync = config.get_by_tabname('mam_sync', self.jid) if use_log and mam_sync: - self.mam_filler = MAMFiller(logger, self) + limit = config.get_by_tabname('mam_sync_limit', self.jid) + self.mam_filler = MAMFiller(logger, self, limit) asyncio.ensure_future( LogLoader(logger, self, use_log).tab_open() ) diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py index c48ccebc..85aa0eff 100644 --- a/poezio/tabs/muctab.py +++ b/poezio/tabs/muctab.py @@ -181,7 +181,8 @@ class MucTab(ChatTab): use_log = config.get_by_tabname('mam_sync', self.general_jid) mam_sync = config.get_by_tabname('mam_sync', self.general_jid) if self.mam_filler is None and use_log and mam_sync: - self.mam_filler = MAMFiller(logger, self) + limit = config.get_by_tabname('mam_sync_limit', self.jid) + self.mam_filler = MAMFiller(logger, self, limit) muc.join_groupchat( self.core, self.jid.bare, |