From 92980bf427b0630d4405fedec384c2e24ccccab9 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Thu, 21 May 2020 01:29:41 +0200 Subject: Increase typing duration Slack only sends typing notices every 5-6 seconds, so when we expired them after 4, a user which continously typed a message would disappear from the typing bar every 4 seconds and appear again after a second. Now they are shown continously, and for about the same duration as the web client. --- wee_slack.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'wee_slack.py') diff --git a/wee_slack.py b/wee_slack.py index 2f5560e..5f93a60 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -66,6 +66,7 @@ REPO_URL = "https://github.com/wee-slack/wee-slack" BACKLOG_SIZE = 200 SCROLLBACK_SIZE = 500 +TYPING_DURATION = 6 RECORD_DIR = "/tmp/weeslack-debug" @@ -1965,10 +1966,11 @@ class SlackChannel(SlackChannelCommon): returns if any of them is actively typing. If none are, nulls the dict and returns false. """ - for user, timestamp in self.typing.items(): - if timestamp + 4 > time.time(): + typing_expire_time = time.time() - TYPING_DURATION + for timestamp in self.typing.values(): + if timestamp > typing_expire_time: return True - if len(self.typing) > 0: + if self.typing: self.typing = {} self.eventrouter.weechat_controller.set_refresh_buffer_list(True) return False @@ -1977,9 +1979,10 @@ class SlackChannel(SlackChannelCommon): """ Returns the names of everyone in the channel who is currently typing. """ + typing_expire_time = time.time() - TYPING_DURATION typing = [] for user, timestamp in self.typing.items(): - if timestamp + 4 > time.time(): + if timestamp > typing_expire_time: typing.append(user) else: del self.typing[user] -- cgit