aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2018-08-18 16:19:15 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2018-08-18 16:19:15 +0200
commit71a2e61e21c869e49c45549bf9176cdc63bb1e80 (patch)
tree45a1d773176143d3ef989dbbf97f59293bbac825
parente1d1ed78763560f37da243294712381235179004 (diff)
downloadwee-slack-71a2e61e21c869e49c45549bf9176cdc63bb1e80.tar.gz
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).
-rw-r--r--wee_slack.py6
1 files changed, 4 insertions, 2 deletions
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)