diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2020-05-21 01:29:41 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2020-05-22 21:27:30 +0200 |
commit | 92980bf427b0630d4405fedec384c2e24ccccab9 (patch) | |
tree | fe30d9926b7733723e635fded9fe67f4c6685787 /wee_slack.py | |
parent | 7ef5eb3f0564075fefa240c2a2de3cb0b9f85eca (diff) | |
download | wee-slack-92980bf427b0630d4405fedec384c2e24ccccab9.tar.gz |
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.
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 11 |
1 files changed, 7 insertions, 4 deletions
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] |