diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-10-01 21:31:08 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:54 +0100 |
commit | 6cf20324f97fa49bade19ecf1f46e2900c2eda08 (patch) | |
tree | a4322caa518f577d8d7154cf4a45509b726ecfb3 /slack/slack_conversation.py | |
parent | 2733d6a0faf3ea9150ee8e16950ca3d54a6361e6 (diff) | |
download | wee-slack-6cf20324f97fa49bade19ecf1f46e2900c2eda08.tar.gz |
Correctly tag unread messages from history
Now notify tags are set based on last_read so both read and unread
messages gets the correct tags irregardless if they come from history or
websocket.
Diffstat (limited to 'slack/slack_conversation.py')
-rw-r--r-- | slack/slack_conversation.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py index 97fd85b..cb5e53f 100644 --- a/slack/slack_conversation.py +++ b/slack/slack_conversation.py @@ -152,6 +152,10 @@ class SlackConversation(SlackBuffer): def buffer_type(self) -> Literal["private", "channel"]: return "private" if self.type in ("im", "mpim") else "channel" + @property + def last_read(self) -> SlackTs: + return SlackTs(self._info["last_read"]) + async def sort_key(self) -> str: type_sort_key = { "channel": 0, @@ -335,7 +339,7 @@ class SlackConversation(SlackBuffer): await gather(*(message.render(self.context) for message in messages)) for message in messages: - await self.print_message(message, backlog=True) + await self.print_message(message) self.history_filled = True self.history_pending = False @@ -512,8 +516,8 @@ class SlackConversation(SlackBuffer): thread_message.thread_buffer = SlackThread(thread_message) await thread_message.thread_buffer.open_buffer(switch) - async def print_message(self, message: SlackMessage, backlog: bool = False): - await super().print_message(message, backlog) + async def print_message(self, message: SlackMessage): + await super().print_message(message) sender = await message.sender if message.subtype in ["channel_leave", "group_leave"]: self.nicklist_remove_user(sender) |