From def167791d099ffecb5a4b5a5582dce99e319987 Mon Sep 17 00:00:00 2001 From: mathieui Date: Tue, 15 Feb 2022 23:05:23 +0100 Subject: 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) --- poezio/tabs/basetabs.py | 3 ++- poezio/tabs/conversationtab.py | 1 + poezio/tabs/privatetab.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'poezio/tabs') diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py index c88a8a10..44330782 100644 --- a/poezio/tabs/basetabs.py +++ b/poezio/tabs/basetabs.py @@ -1000,6 +1000,7 @@ class OneToOneTab(ChatTab): self.__status = Status("", "") self.last_remote_message = datetime.now() + self._initial_log = asyncio.Event() # Set to true once the first disco is done self.__initial_disco = False @@ -1036,7 +1037,7 @@ class OneToOneTab(ChatTab): elif use_log and initial: asyncio.create_task(self.handle_message(initial, display=False)) asyncio.create_task( - LogLoader(logger, self, use_log).tab_open() + LogLoader(logger, self, use_log, self._initial_log).tab_open() ) async def handle_message(self, msg: SMessage, display: bool = True): diff --git a/poezio/tabs/conversationtab.py b/poezio/tabs/conversationtab.py index 76c86d70..14a6be64 100644 --- a/poezio/tabs/conversationtab.py +++ b/poezio/tabs/conversationtab.py @@ -173,6 +173,7 @@ class ConversationTab(OneToOneTab): @refresh_wrapper.always @command_args_parser.raw async def command_say(self, line: str, attention: bool = False, correct: bool = False): + await self._initial_log.wait() msg: SMessage = self.core.xmpp.make_message( mto=self.get_dest_jid(), mfrom=self.core.xmpp.boundjid diff --git a/poezio/tabs/privatetab.py b/poezio/tabs/privatetab.py index 9ed968b7..c68e5d2e 100644 --- a/poezio/tabs/privatetab.py +++ b/poezio/tabs/privatetab.py @@ -205,6 +205,7 @@ class PrivateTab(OneToOneTab): async def command_say(self, line: str, attention: bool = False, correct: bool = False) -> None: if not self.on: return + await self._initial_log.wait() our_jid = JID(self.jid.bare) our_jid.resource = self.own_nick msg: SMessage = self.core.xmpp.make_message( -- cgit v1.2.3