From 30eea6bb1f4278b79583e8130aef5e404411a31b Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Fri, 1 Sep 2023 22:46:14 +0200 Subject: Create a readonly messages property instead of get_message --- slack/slack_conversation.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'slack/slack_conversation.py') diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py index 20b1085..fd73385 100644 --- a/slack/slack_conversation.py +++ b/slack/slack_conversation.py @@ -4,7 +4,7 @@ import hashlib import time from collections import OrderedDict from contextlib import contextmanager -from typing import TYPE_CHECKING, Dict, List, NoReturn, Optional, Union +from typing import TYPE_CHECKING, Dict, List, Mapping, NoReturn, Optional, Union import weechat @@ -196,11 +196,10 @@ class SlackConversationMessageHashes(Dict[SlackTs, str]): self._setitem(ts_with_same_hash, other_short_hash) self._inverse_map[other_short_hash] = ts_with_same_hash - other_message = self._conversation.get_message(ts_with_same_hash) - if other_message: - run_async(self._conversation.rerender_message(other_message)) - for reply in other_message.replies: - run_async(self._conversation.rerender_message(reply)) + other_message = self._conversation.messages[ts_with_same_hash] + run_async(self._conversation.rerender_message(other_message)) + for reply in other_message.replies: + run_async(self._conversation.rerender_message(reply)) self._setitem(key, short_hash) self._inverse_map[short_hash] = key @@ -248,6 +247,10 @@ class SlackConversation: def id(self) -> str: return self._info["id"] + @property + def messages(self) -> Mapping[SlackTs, SlackMessage]: + return self._messages + @property def type(self) -> Literal["channel", "private", "mpim", "im"]: if self._info["is_im"] is True: @@ -313,9 +316,6 @@ class SlackConversation: finally: self.completion_context = "ACTIVE_COMPLETION" - def get_message(self, ts: SlackTs) -> Optional[SlackMessage]: - return self._messages.get(ts) - async def open_if_open(self): if "is_open" in self._info: if self._info["is_open"]: -- cgit