diff options
author | Maxime “pep” Buquet <pep@bouah.net> | 2022-03-31 11:53:34 +0200 |
---|---|---|
committer | Maxime “pep” Buquet <pep@bouah.net> | 2022-03-31 11:53:34 +0200 |
commit | b7ae221e0e915e194e66ff55d1130228e2f56b38 (patch) | |
tree | 9b77fec7f05ec98a7b1966f0c7a5550dc29ffb8d | |
parent | afae22656250c231d3ce03acc134d15bc40af6b9 (diff) | |
download | poezio-b7ae221e0e915e194e66ff55d1130228e2f56b38.tar.gz poezio-b7ae221e0e915e194e66ff55d1130228e2f56b38.tar.bz2 poezio-b7ae221e0e915e194e66ff55d1130228e2f56b38.tar.xz poezio-b7ae221e0e915e194e66ff55d1130228e2f56b38.zip |
OneToOneTab: convert init_logs to async
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r-- | poezio/tabs/basetabs.py | 21 | ||||
-rw-r--r-- | poezio/tabs/conversationtab.py | 2 |
2 files changed, 9 insertions, 14 deletions
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py index a0fce822..de88a6d1 100644 --- a/poezio/tabs/basetabs.py +++ b/poezio/tabs/basetabs.py @@ -1016,9 +1016,9 @@ class OneToOneTab(ChatTab): shortdesc='Request the attention.', desc='Attention: Request the attention of the contact. Can also ' 'send a message along with the attention.') - self.init_logs(initial=initial) + asyncio.create_task(self.init_logs(initial=initial)) - def init_logs(self, initial: Optional[SMessage] = None) -> None: + async def init_logs(self, initial: Optional[SMessage] = None) -> None: 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: @@ -1029,19 +1029,14 @@ class OneToOneTab(ChatTab): if initial is not None: # If there is an initial message, throw it back into the # text buffer if it cannot be fetched from mam - async def fallback_no_mam() -> None: - await mam_filler.done.wait() - if mam_filler.result == 0: - await self.handle_message(initial) - - asyncio.create_task(fallback_no_mam()) + await mam_filler.done.wait() + if mam_filler.result == 0: + await self.handle_message(initial) elif use_log and initial: - asyncio.create_task(self.handle_message(initial, display=False)) + await self.handle_message(initial, display=False) elif initial: - asyncio.create_task(self.handle_message(initial)) - asyncio.create_task( - LogLoader(logger, self, use_log, self._initial_log).tab_open() - ) + await self.handle_message(initial) + await LogLoader(logger, self, use_log, self._initial_log).tab_open() async def handle_message(self, msg: SMessage, display: bool = True): pass diff --git a/poezio/tabs/conversationtab.py b/poezio/tabs/conversationtab.py index 14a6be64..d3a1640c 100644 --- a/poezio/tabs/conversationtab.py +++ b/poezio/tabs/conversationtab.py @@ -540,7 +540,7 @@ class StaticConversationTab(ConversationTab): self.update_commands() self.update_keys() - def init_logs(self, initial=None) -> None: + async def init_logs(self, initial=None) -> None: # Disable local logs because… pass |