diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-09-17 12:30:48 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:54 +0100 |
commit | c102376e7b3052126680465c3f99c1b3818ed697 (patch) | |
tree | aebe387ef1f6d79a3f07df7f68e5f2ad3e78ebd8 /slack | |
parent | 94ef876bd1b1c94e03b389183160bf8373b96114 (diff) | |
download | wee-slack-c102376e7b3052126680465c3f99c1b3818ed697.tar.gz |
Make sure thread prefix is rendered even though parent isn't fetched
Diffstat (limited to 'slack')
-rw-r--r-- | slack/slack_conversation.py | 5 | ||||
-rw-r--r-- | slack/slack_message.py | 10 |
2 files changed, 9 insertions, 6 deletions
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: |