From dce234ea366d688a0aa899aa1bc4cf56a2d1a009 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Wed, 30 Aug 2023 23:24:55 +0200 Subject: Display the correct thread messages in channels Both when filling from history and on new messages, only display thread messages in channels if they're either a thread broadcast or if the option to display thread messages in channels is enabled. --- slack/slack_conversation.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'slack/slack_conversation.py') diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py index 982f06a..20b1085 100644 --- a/slack/slack_conversation.py +++ b/slack/slack_conversation.py @@ -405,7 +405,8 @@ class SlackConversation: await gather(*(message.render() for message in messages)) for message in reversed(messages): - await self.print_message(message, backlog=True) + if self.should_display_message(message): + await self.print_message(message, backlog=True) self.history_filled = True self.history_pending = False @@ -433,11 +434,18 @@ class SlackConversation: return bool(weechat.config_string_to_boolean(buffer_value)) return shared.config.look.display_thread_replies_in_channel.value + def should_display_message(self, message: SlackMessage) -> bool: + return ( + not message.is_reply + or message.is_thread_broadcast + or self.display_thread_replies() + ) + async def add_new_message(self, message: SlackMessage): # TODO: Remove old messages self._messages[message.ts] = message - if not message.is_reply or self.display_thread_replies(): + if self.should_display_message(message): if self.history_filled: await self.print_message(message) else: -- cgit