diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-10-02 00:19:45 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:54 +0100 |
commit | 12ce8befda90d79ff3c1533770e38f865728482f (patch) | |
tree | 16bd450c00441b515519da69b88b9a40df8550d5 /slack/slack_buffer.py | |
parent | 91312364d70efaa3a0c6d4e8a15965383df5fcf7 (diff) | |
download | wee-slack-12ce8befda90d79ff3c1533770e38f865728482f.tar.gz |
Mark as read when switching away from buffer
Diffstat (limited to 'slack/slack_buffer.py')
-rw-r--r-- | slack/slack_buffer.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/slack/slack_buffer.py b/slack/slack_buffer.py index e2cdeac..3da8aad 100644 --- a/slack/slack_buffer.py +++ b/slack/slack_buffer.py @@ -259,6 +259,29 @@ class SlackBuffer(ABC): if backlog: weechat.buffer_set(self.buffer_pointer, "unread", "") + def last_read_line_ts(self) -> Optional[SlackTs]: + if self.buffer_pointer: + own_lines = weechat.hdata_pointer( + weechat.hdata_get("buffer"), self.buffer_pointer, "own_lines" + ) + first_line_not_read = weechat.hdata_integer( + weechat.hdata_get("lines"), own_lines, "first_line_not_read" + ) + if first_line_not_read: + return + line = weechat.hdata_pointer( + weechat.hdata_get("lines"), own_lines, "last_read_line" + ) + while line: + ts = hdata_line_ts(line) + if ts: + return ts + line = weechat.hdata_move(weechat.hdata_get("line"), line, -1) + + @abstractmethod + async def mark_read(self) -> None: + raise NotImplementedError() + def set_unread_and_hotlist(self): if self.buffer_pointer: # TODO: Move unread marker to correct position according to last_read for WeeChat >= 4.0.0 |