diff options
author | mathieui <mathieui@mathieui.net> | 2021-06-22 23:16:42 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2021-06-22 23:26:49 +0200 |
commit | 2b76f72e4d58eb540aa19173a050142f5199ff81 (patch) | |
tree | ccca7dbf36c20e980e3a69c0028af264702c75f6 /poezio/tabs/basetabs.py | |
parent | 3035f4ed4d5ef5d581c7f224833392526bfd1bc5 (diff) | |
download | poezio-2b76f72e4d58eb540aa19173a050142f5199ff81.tar.gz poezio-2b76f72e4d58eb540aa19173a050142f5199ff81.tar.bz2 poezio-2b76f72e4d58eb540aa19173a050142f5199ff81.tar.xz poezio-2b76f72e4d58eb540aa19173a050142f5199ff81.zip |
Fix the message doubling situation
Add an "initial" parameter for onetoonetabs, and delay the reception of
the message until the sync is done (and possibly ignore the message if
it is fetched by the sync).
Fixes #3542
Diffstat (limited to 'poezio/tabs/basetabs.py')
-rw-r--r-- | poezio/tabs/basetabs.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py index 43ab237f..f52122a5 100644 --- a/poezio/tabs/basetabs.py +++ b/poezio/tabs/basetabs.py @@ -999,7 +999,7 @@ class ChatTab(Tab): class OneToOneTab(ChatTab): - def __init__(self, core, jid): + def __init__(self, core, jid, initial=None): ChatTab.__init__(self, core, jid) self.__status = Status("", "") @@ -1018,18 +1018,29 @@ 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() + self.init_logs(initial=initial) - def init_logs(self) -> None: + def init_logs(self, initial=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: limit = config.get_by_tabname('mam_sync_limit', self.jid) self.mam_filler = MAMFiller(logger, self, limit) + + async def fallback_no_mam(): + await self.mam_filler.done.wait() + if self.mam_filler.result == 0: + self.handle_message(initial) + asyncio.ensure_future(fallback_no_mam()) + elif use_log and initial: + self.handle_message(initial, display=False) asyncio.ensure_future( LogLoader(logger, self, use_log).tab_open() ) + def handle_message(self, msg: SMessage, display: bool = True): + pass + def remote_user_color(self): return dump_tuple(get_theme().COLOR_REMOTE_USER) |