aboutsummaryrefslogtreecommitdiffstats
path: root/slack/slack_buffer.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-10-01 21:31:08 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:54 +0100
commit6cf20324f97fa49bade19ecf1f46e2900c2eda08 (patch)
treea4322caa518f577d8d7154cf4a45509b726ecfb3 /slack/slack_buffer.py
parent2733d6a0faf3ea9150ee8e16950ca3d54a6361e6 (diff)
downloadwee-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_buffer.py')
-rw-r--r--slack/slack_buffer.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/slack/slack_buffer.py b/slack/slack_buffer.py
index 0e16845..18a0f89 100644
--- a/slack/slack_buffer.py
+++ b/slack/slack_buffer.py
@@ -176,6 +176,11 @@ class SlackBuffer(ABC):
def messages(self) -> Mapping[SlackTs, SlackMessage]:
raise NotImplementedError()
+ @property
+ @abstractmethod
+ def last_read(self) -> SlackTs:
+ raise NotImplementedError()
+
@abstractmethod
async def get_name_and_buffer_props(self) -> Tuple[str, Dict[str, str]]:
raise NotImplementedError()
@@ -246,9 +251,10 @@ class SlackBuffer(ABC):
self._typing_self_last_sent = now
self.workspace.send_typing(self)
- async def print_message(self, message: SlackMessage, backlog: bool = False):
+ async def print_message(self, message: SlackMessage):
rendered = await message.render(self.context)
- tags = await message.tags(backlog=backlog)
+ backlog = message.ts <= self.last_read
+ tags = await message.tags(backlog)
weechat.prnt_date_tags(self.buffer_pointer, message.ts.major, tags, rendered)
def _buffer_input_cb(self, data: str, buffer: str, input_data: str) -> int: