diff options
author | mathieui <mathieui@mathieui.net> | 2021-04-11 13:03:32 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2021-04-11 16:33:53 +0200 |
commit | a827743b8677ff9bb4ea63bbb1ac690fdfcb6457 (patch) | |
tree | 830d69d5e1a39a5ffa51538d610037b1c41f268a | |
parent | f6ba263305da5c5501bda8e22532852a3c9ea230 (diff) | |
download | poezio-a827743b8677ff9bb4ea63bbb1ac690fdfcb6457.tar.gz poezio-a827743b8677ff9bb4ea63bbb1ac690fdfcb6457.tar.bz2 poezio-a827743b8677ff9bb4ea63bbb1ac690fdfcb6457.tar.xz poezio-a827743b8677ff9bb4ea63bbb1ac690fdfcb6457.zip |
internal: make the MAMFiller an attribute of ChatTabs
and fetch logs in conversationtabs and privatetabs
-rw-r--r-- | poezio/tabs/basetabs.py | 5 | ||||
-rw-r--r-- | poezio/tabs/conversationtab.py | 9 | ||||
-rw-r--r-- | poezio/tabs/muctab.py | 5 | ||||
-rw-r--r-- | poezio/tabs/privatetab.py | 9 |
4 files changed, 21 insertions, 7 deletions
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py index 0a31931b..d7dac0e0 100644 --- a/poezio/tabs/basetabs.py +++ b/poezio/tabs/basetabs.py @@ -45,6 +45,7 @@ from poezio.core.structs import Command, Completion, Status from poezio.config import config from poezio.decorators import command_args_parser, refresh_wrapper from poezio.logger import logger +from poezio.log_loader import MAMFiller from poezio.text_buffer import TextBuffer from poezio.theming import get_theme, dump_tuple from poezio.user import User @@ -511,6 +512,7 @@ class ChatTab(Tab): message_type = 'chat' timed_event_paused: Optional[DelayedEvent] timed_event_not_paused: Optional[DelayedEvent] + mam_filler: Optional[MAMFiller] def __init__(self, core, jid: Union[JID, str]): Tab.__init__(self, core) @@ -526,6 +528,7 @@ class ChatTab(Tab): self.directed_presence = None self._text_buffer = TextBuffer() self._text_buffer.add_window(self.text_win) + self.mam_filler = None self.chatstate = None # can be "active", "composing", "paused", "gone", "inactive" # We keep a reference of the event that will set our chatstate to "paused", so that # we can delete it or change it if we need to @@ -967,7 +970,7 @@ class ChatTab(Tab): if not self.query_status: from poezio.log_loader import LogLoader asyncio.ensure_future( - LogLoader(logger, self, config.get('use_log')).scroll_requested() + LogLoader(logger, self, config.getbool('use_log')).scroll_requested() ) return self.text_win.scroll_up(self.text_win.height - 1) diff --git a/poezio/tabs/conversationtab.py b/poezio/tabs/conversationtab.py index 8f608e84..8b06c5fc 100644 --- a/poezio/tabs/conversationtab.py +++ b/poezio/tabs/conversationtab.py @@ -11,6 +11,7 @@ There are two different instances of a ConversationTab: the time. """ +import asyncio import curses import logging from typing import Dict, Callable @@ -20,12 +21,13 @@ from poezio.tabs.basetabs import OneToOneTab, Tab from poezio import common from poezio import windows from poezio import xhtml +from poezio.log_loader import MAMFiller, LogLoader +from poezio.logger import logger from poezio.common import safeJID from poezio.config import config from poezio.core.structs import Command from poezio.decorators import refresh_wrapper from poezio.roster import roster -from poezio.text_buffer import CorrectionError from poezio.theming import get_theme, dump_tuple from poezio.decorators import command_args_parser from poezio.ui.types import InfoMessage @@ -387,6 +389,11 @@ class DynamicConversationTab(ConversationTab): self.resize() self.update_commands() self.update_keys() + if config.getbool('mam_sync'): + self.mam_filler = MAMFiller(logger, self) + asyncio.ensure_future( + LogLoader(logger, self, config.getbool('use_log')).tab_open() + ) def get_info_header(self): return self.info_header diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py index 9334ce4c..593be6ce 100644 --- a/poezio/tabs/muctab.py +++ b/poezio/tabs/muctab.py @@ -84,7 +84,6 @@ class MucTab(ChatTab): plugin_keys: Dict[str, Callable[..., Any]] = {} additional_information: Dict[str, Callable[[str], str]] = {} lagged: bool = False - mam_filler: Optional[MAMFiller] def __init__(self, core: Core, jid: JID, nick: str, password: Optional[str] = None) -> None: ChatTab.__init__(self, core, jid) @@ -105,7 +104,6 @@ class MucTab(ChatTab): self.topic_from = '' # Self ping event, so we can cancel it when we leave the room self.self_ping_event: Optional[timed_events.DelayedEvent] = None - self.mam_filler = None # UI stuff self.topic_win = windows.Topic() self.v_separator = windows.VerticalSeparator() @@ -181,7 +179,8 @@ class MucTab(ChatTab): seconds = None if last_message is not None: seconds = (datetime.now() - last_message.time).seconds - self.mam_filler = MAMFiller(self, logger) + if self.mam_filler is None and config.getbool('mam_sync'): + self.mam_filler = MAMFiller(logger, self) muc.join_groupchat( self.core, self.jid.bare, diff --git a/poezio/tabs/privatetab.py b/poezio/tabs/privatetab.py index 526a7570..2d4a73e1 100644 --- a/poezio/tabs/privatetab.py +++ b/poezio/tabs/privatetab.py @@ -10,6 +10,7 @@ both participant’s nicks. It also has slightly different features than the ConversationTab (such as tab-completion on nicks from the room). """ +import asyncio import curses import logging from typing import Dict, Callable @@ -24,11 +25,10 @@ from poezio.config import config from poezio.core.structs import Command from poezio.decorators import refresh_wrapper from poezio.logger import logger +from poezio.log_loader import LogLoader, MAMFiller from poezio.theming import get_theme, dump_tuple from poezio.decorators import command_args_parser from poezio.ui.types import ( - BaseMessage, - InfoMessage, Message, PersistentInfoMessage, ) @@ -70,6 +70,11 @@ class PrivateTab(OneToOneTab): self.on = True self.update_commands() self.update_keys() + if config.getbool('mam_sync'): + self.mam_filler = MAMFiller(logger, self) + asyncio.ensure_future( + LogLoader(logger, self, config.getbool('use_log')).tab_open() + ) @property def log_name(self) -> str: |