From 71a2e61e21c869e49c45549bf9176cdc63bb1e80 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sat, 18 Aug 2018 16:19:15 +0200 Subject: Set last_read when marking channel as read This fixes a bug where old messages would show up as new instead of as backlog messages when channel history is reloaded (i.e. when running /rehistory or after reconnects). --- wee_slack.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'wee_slack.py') diff --git a/wee_slack.py b/wee_slack.py index 4eec7fb..e53076f 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1590,12 +1590,14 @@ class SlackChannel(object): return typing def mark_read(self, ts=None, update_remote=True, force=False): - if not ts: - ts = next(self.main_message_keys_reversed(), SlackTS()) if self.new_messages or force: if self.channel_buffer: w.buffer_set(self.channel_buffer, "unread", "") w.buffer_set(self.channel_buffer, "hotlist", "-1") + if not ts: + ts = next(self.main_message_keys_reversed(), SlackTS()) + if ts > self.last_read: + self.last_read = ts if update_remote: s = SlackRequest(self.team.token, SLACK_API_TRANSLATOR[self.type]["mark"], {"channel": self.identifier, "ts": ts}, team_hash=self.team.team_hash, channel_identifier=self.identifier) self.eventrouter.receive(s) -- cgit