diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2020-04-20 08:53:28 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2020-05-30 21:11:27 +0200 |
commit | 1faa03482a874abf96f82a7b486ae2a65087e694 (patch) | |
tree | 073cc749ba65243769753c25879419e9fb4342b6 /wee_slack.py | |
parent | ae81365066227a484ca0c5daba092047cb6062b5 (diff) | |
download | wee-slack-1faa03482a874abf96f82a7b486ae2a65087e694.tar.gz |
Only load history after latest message after reconnect
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py index b97b1d4..374a60e 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -886,7 +886,7 @@ def buffer_switch_callback(signal, sig_type, data): new_channel = eventrouter.weechat_controller.get_channel_from_buffer_ptr(data) if new_channel: - if not new_channel.got_history: + if not new_channel.got_history or new_channel.history_needs_update: new_channel.get_history() set_own_presence_active(new_channel.team) @@ -1292,6 +1292,7 @@ class SlackTeam(object): self.name = self.domain self.channel_buffer = None self.got_history = True + self.history_needs_update = False self.create_buffer() self.set_muted_channels(kwargs.get('muted_channels', "")) self.set_highlight_words(kwargs.get('highlight_words', "")) @@ -1433,7 +1434,7 @@ class SlackTeam(object): elif not self.connecting_rtm: # The fast reconnect failed, so start over-ish for chan in self.channels: - self.channels[chan].got_history = False + self.channels[chan].history_needs_update = True s = initiate_connection(self.token, retries=999, team=self) self.eventrouter.receive(s) self.connecting_rtm = True @@ -1689,6 +1690,7 @@ class SlackChannel(SlackChannelCommon): self.last_read = SlackTS(kwargs.get("last_read", SlackTS())) self.channel_buffer = None self.got_history = False + self.history_needs_update = False self.messages = OrderedDict() self.hashed_messages = {} self.thread_channels = {} @@ -1971,6 +1973,7 @@ class SlackChannel(SlackChannelCommon): else: self.eventrouter.receive_slow(s) self.got_history = True + self.history_needs_update = False def main_message_keys_reversed(self): return (key for key in reversed(self.messages) @@ -2250,6 +2253,7 @@ class SlackThreadChannel(SlackChannelCommon): self.channel_buffer = None self.type = "thread" self.got_history = False + self.history_needs_update = False self.label = None self.team = self.parent_message.team self.last_line_from = None @@ -2315,6 +2319,7 @@ class SlackThreadChannel(SlackChannelCommon): def get_history(self): self.got_history = True + self.history_needs_update = False self.print_messages(history_message=True) if len(self.parent_message.submessages) < self.parent_message.number_of_replies(): s = SlackRequest(self.team, "conversations.replies", |