internal: make the MAMFiller an attribute of ChatTabs
and fetch logs in conversationtabs and privatetabs
This commit is contained in:
parent
f6ba263305
commit
a827743b86
4 changed files with 21 additions and 7 deletions
|
@ -45,6 +45,7 @@ from poezio.core.structs import Command, Completion, Status
|
||||||
from poezio.config import config
|
from poezio.config import config
|
||||||
from poezio.decorators import command_args_parser, refresh_wrapper
|
from poezio.decorators import command_args_parser, refresh_wrapper
|
||||||
from poezio.logger import logger
|
from poezio.logger import logger
|
||||||
|
from poezio.log_loader import MAMFiller
|
||||||
from poezio.text_buffer import TextBuffer
|
from poezio.text_buffer import TextBuffer
|
||||||
from poezio.theming import get_theme, dump_tuple
|
from poezio.theming import get_theme, dump_tuple
|
||||||
from poezio.user import User
|
from poezio.user import User
|
||||||
|
@ -511,6 +512,7 @@ class ChatTab(Tab):
|
||||||
message_type = 'chat'
|
message_type = 'chat'
|
||||||
timed_event_paused: Optional[DelayedEvent]
|
timed_event_paused: Optional[DelayedEvent]
|
||||||
timed_event_not_paused: Optional[DelayedEvent]
|
timed_event_not_paused: Optional[DelayedEvent]
|
||||||
|
mam_filler: Optional[MAMFiller]
|
||||||
|
|
||||||
def __init__(self, core, jid: Union[JID, str]):
|
def __init__(self, core, jid: Union[JID, str]):
|
||||||
Tab.__init__(self, core)
|
Tab.__init__(self, core)
|
||||||
|
@ -526,6 +528,7 @@ class ChatTab(Tab):
|
||||||
self.directed_presence = None
|
self.directed_presence = None
|
||||||
self._text_buffer = TextBuffer()
|
self._text_buffer = TextBuffer()
|
||||||
self._text_buffer.add_window(self.text_win)
|
self._text_buffer.add_window(self.text_win)
|
||||||
|
self.mam_filler = None
|
||||||
self.chatstate = None # can be "active", "composing", "paused", "gone", "inactive"
|
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 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
|
# we can delete it or change it if we need to
|
||||||
|
@ -967,7 +970,7 @@ class ChatTab(Tab):
|
||||||
if not self.query_status:
|
if not self.query_status:
|
||||||
from poezio.log_loader import LogLoader
|
from poezio.log_loader import LogLoader
|
||||||
asyncio.ensure_future(
|
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)
|
return self.text_win.scroll_up(self.text_win.height - 1)
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ There are two different instances of a ConversationTab:
|
||||||
the time.
|
the time.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
import asyncio
|
||||||
import curses
|
import curses
|
||||||
import logging
|
import logging
|
||||||
from typing import Dict, Callable
|
from typing import Dict, Callable
|
||||||
|
@ -20,12 +21,13 @@ from poezio.tabs.basetabs import OneToOneTab, Tab
|
||||||
from poezio import common
|
from poezio import common
|
||||||
from poezio import windows
|
from poezio import windows
|
||||||
from poezio import xhtml
|
from poezio import xhtml
|
||||||
|
from poezio.log_loader import MAMFiller, LogLoader
|
||||||
|
from poezio.logger import logger
|
||||||
from poezio.common import safeJID
|
from poezio.common import safeJID
|
||||||
from poezio.config import config
|
from poezio.config import config
|
||||||
from poezio.core.structs import Command
|
from poezio.core.structs import Command
|
||||||
from poezio.decorators import refresh_wrapper
|
from poezio.decorators import refresh_wrapper
|
||||||
from poezio.roster import roster
|
from poezio.roster import roster
|
||||||
from poezio.text_buffer import CorrectionError
|
|
||||||
from poezio.theming import get_theme, dump_tuple
|
from poezio.theming import get_theme, dump_tuple
|
||||||
from poezio.decorators import command_args_parser
|
from poezio.decorators import command_args_parser
|
||||||
from poezio.ui.types import InfoMessage
|
from poezio.ui.types import InfoMessage
|
||||||
|
@ -387,6 +389,11 @@ class DynamicConversationTab(ConversationTab):
|
||||||
self.resize()
|
self.resize()
|
||||||
self.update_commands()
|
self.update_commands()
|
||||||
self.update_keys()
|
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):
|
def get_info_header(self):
|
||||||
return self.info_header
|
return self.info_header
|
||||||
|
|
|
@ -84,7 +84,6 @@ class MucTab(ChatTab):
|
||||||
plugin_keys: Dict[str, Callable[..., Any]] = {}
|
plugin_keys: Dict[str, Callable[..., Any]] = {}
|
||||||
additional_information: Dict[str, Callable[[str], str]] = {}
|
additional_information: Dict[str, Callable[[str], str]] = {}
|
||||||
lagged: bool = False
|
lagged: bool = False
|
||||||
mam_filler: Optional[MAMFiller]
|
|
||||||
|
|
||||||
def __init__(self, core: Core, jid: JID, nick: str, password: Optional[str] = None) -> None:
|
def __init__(self, core: Core, jid: JID, nick: str, password: Optional[str] = None) -> None:
|
||||||
ChatTab.__init__(self, core, jid)
|
ChatTab.__init__(self, core, jid)
|
||||||
|
@ -105,7 +104,6 @@ class MucTab(ChatTab):
|
||||||
self.topic_from = ''
|
self.topic_from = ''
|
||||||
# Self ping event, so we can cancel it when we leave the room
|
# Self ping event, so we can cancel it when we leave the room
|
||||||
self.self_ping_event: Optional[timed_events.DelayedEvent] = None
|
self.self_ping_event: Optional[timed_events.DelayedEvent] = None
|
||||||
self.mam_filler = None
|
|
||||||
# UI stuff
|
# UI stuff
|
||||||
self.topic_win = windows.Topic()
|
self.topic_win = windows.Topic()
|
||||||
self.v_separator = windows.VerticalSeparator()
|
self.v_separator = windows.VerticalSeparator()
|
||||||
|
@ -181,7 +179,8 @@ class MucTab(ChatTab):
|
||||||
seconds = None
|
seconds = None
|
||||||
if last_message is not None:
|
if last_message is not None:
|
||||||
seconds = (datetime.now() - last_message.time).seconds
|
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(
|
muc.join_groupchat(
|
||||||
self.core,
|
self.core,
|
||||||
self.jid.bare,
|
self.jid.bare,
|
||||||
|
|
|
@ -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).
|
the ConversationTab (such as tab-completion on nicks from the room).
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
import asyncio
|
||||||
import curses
|
import curses
|
||||||
import logging
|
import logging
|
||||||
from typing import Dict, Callable
|
from typing import Dict, Callable
|
||||||
|
@ -24,11 +25,10 @@ from poezio.config import config
|
||||||
from poezio.core.structs import Command
|
from poezio.core.structs import Command
|
||||||
from poezio.decorators import refresh_wrapper
|
from poezio.decorators import refresh_wrapper
|
||||||
from poezio.logger import logger
|
from poezio.logger import logger
|
||||||
|
from poezio.log_loader import LogLoader, MAMFiller
|
||||||
from poezio.theming import get_theme, dump_tuple
|
from poezio.theming import get_theme, dump_tuple
|
||||||
from poezio.decorators import command_args_parser
|
from poezio.decorators import command_args_parser
|
||||||
from poezio.ui.types import (
|
from poezio.ui.types import (
|
||||||
BaseMessage,
|
|
||||||
InfoMessage,
|
|
||||||
Message,
|
Message,
|
||||||
PersistentInfoMessage,
|
PersistentInfoMessage,
|
||||||
)
|
)
|
||||||
|
@ -70,6 +70,11 @@ class PrivateTab(OneToOneTab):
|
||||||
self.on = True
|
self.on = True
|
||||||
self.update_commands()
|
self.update_commands()
|
||||||
self.update_keys()
|
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
|
@property
|
||||||
def log_name(self) -> str:
|
def log_name(self) -> str:
|
||||||
|
|
Loading…
Reference in a new issue