summaryrefslogtreecommitdiff
path: root/poezio/log_loader.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2022-02-15 23:05:23 +0100
committerMaxime Buquet <pep@bouah.net>2022-03-23 15:38:00 +0100
commitdef167791d099ffecb5a4b5a5582dce99e319987 (patch)
treec542f6d22bf8c5f8ca3ef42fd2981c74c18132a5 /poezio/log_loader.py
parent6174ca70d9bc36fde9d0a0c08ccb67e874a4711c (diff)
downloadpoezio-def167791d099ffecb5a4b5a5582dce99e319987.tar.gz
poezio-def167791d099ffecb5a4b5a5582dce99e319987.tar.bz2
poezio-def167791d099ffecb5a4b5a5582dce99e319987.tar.xz
poezio-def167791d099ffecb5a4b5a5582dce99e319987.zip
fix: do not triplicate messages on /message tab openings
add a synchronization primitive to avoid /say until the logs are loaded and synced (otherwise we do the /say THEN the message we just sent can be loaded from the archive, while also being displayed)
Diffstat (limited to 'poezio/log_loader.py')
-rw-r--r--poezio/log_loader.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/poezio/log_loader.py b/poezio/log_loader.py
index caee714b..2e3b27c2 100644
--- a/poezio/log_loader.py
+++ b/poezio/log_loader.py
@@ -76,10 +76,17 @@ class LogLoader:
mam_only: bool
def __init__(self, logger: Logger, tab: tabs.ChatTab,
- local_logs: bool = True):
+ local_logs: bool = True,
+ done_event: Optional[asyncio.Event] = None):
self.mam_only = not local_logs
self.logger = logger
self.tab = tab
+ self.done_event = done_event
+
+ def _done(self) -> None:
+ """Signal end if possible"""
+ if self.done_event is not None:
+ self.done_event.set()
async def tab_open(self) -> None:
"""Called on a tab opening or a MUC join"""
@@ -104,6 +111,7 @@ class LogLoader:
if messages:
self.tab._text_buffer.add_history_messages(messages)
self.tab.core.refresh_window()
+ self._done()
async def mam_tab_open(self, nb: int) -> List[BaseMessage]:
"""Fetch messages in MAM when opening a new tab.
@@ -238,6 +246,7 @@ class LogLoader:
if messages:
tab._text_buffer.add_history_messages(messages)
tab.core.refresh_window()
+ self._done()
async def local_scroll_requested(self, nb: int) -> List[BaseMessage]:
"""Fetch messages locally on scroll up.