From c102376e7b3052126680465c3f99c1b3818ed697 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sun, 17 Sep 2023 12:30:48 +0200 Subject: Make sure thread prefix is rendered even though parent isn't fetched --- slack/slack_conversation.py | 5 ++++- slack/slack_message.py | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'slack') diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py index 4baa17c..8d559b0 100644 --- a/slack/slack_conversation.py +++ b/slack/slack_conversation.py @@ -396,7 +396,10 @@ class SlackConversation(SlackBuffer): async def open_thread(self, thread_hash: str, switch: bool = False): thread_ts = self.message_hashes.get_ts(thread_hash) if thread_ts: - thread_message = self.messages[thread_ts] + thread_message = self.messages.get(thread_ts) + if thread_message is None: + # TODO: Fetch message + return if thread_message.thread_buffer is None: thread_message.thread_buffer = SlackThread(thread_message) await thread_message.thread_buffer.open_buffer(switch) diff --git a/slack/slack_message.py b/slack/slack_message.py index c36e052..bb4d141 100644 --- a/slack/slack_message.py +++ b/slack/slack_message.py @@ -175,7 +175,7 @@ class SlackMessage: def parent_message(self) -> Optional[SlackMessage]: if not self.is_reply or self.thread_ts is None: return None - return self.conversation.messages[self.thread_ts] + return self.conversation.messages.get(self.thread_ts) @property def is_bot_message(self) -> bool: @@ -591,17 +591,17 @@ class SlackMessage: return "" def _create_thread_prefix(self) -> str: - parent_message = self.parent_message - if not parent_message: + if not self.is_reply or self.thread_ts is None: return "" + thread_hash = self.conversation.message_hashes[self.thread_ts] broadcast_text = ( shared.config.look.thread_broadcast_prefix.value if self.is_thread_broadcast else "" ) - text = f"[{broadcast_text}{parent_message.hash}]" - return with_color(nick_color(str(parent_message.hash)), text) + " " + text = f"[{broadcast_text}{thread_hash}]" + return with_color(nick_color(thread_hash), text) + " " def _create_thread_string(self) -> str: if "reply_count" not in self._message_json: -- cgit