diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2020-06-07 16:31:24 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2020-06-07 16:32:04 +0200 |
commit | 25ea30b95ec188e230319e43662aef7cf937f7c0 (patch) | |
tree | 55a436b9bc6c04342d692f9c7ae6de8c45e56df4 /wee_slack.py | |
parent | 5096bd6a1e62d3e6b5a2cf9c1b5a169837408e5e (diff) | |
download | wee-slack-25ea30b95ec188e230319e43662aef7cf937f7c0.tar.gz |
On load, fetch history after connected to websocket
The websocket url is only valid for 30 seconds. If wee-slack didn't
manage to connect in time, it would set history_needs_update and
reconnect, but not load history again which meant that each channel
would load history when you switched to the buffer.
I also think there was a slight chance of a message being sent in the
time between history loading and connecting to the websocket, which I
think would mean it would be lost. By fetching history after connecting
to the websocket, this can't happen.
Lastly, by not fetching history before connecting to the websocket, I
think there is less chance of not connecting to the websocket url before
it expires.
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/wee_slack.py b/wee_slack.py index 601a56d..cc2c80c 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1455,7 +1455,7 @@ class SlackTeam(object): self.connecting_ws = False self.ws = ws self.set_reconnect_url(None) - self.set_connected(reconnect) + self.set_connected() elif not self.connecting_rtm: # The fast reconnect failed, so start over-ish for chan in self.channels: @@ -1464,21 +1464,21 @@ class SlackTeam(object): self.eventrouter.receive(s) self.connecting_rtm = True - def set_connected(self, reconnect): + def set_connected(self): self.connected = True self.last_pong_time = time.time() self.buffer_prnt('Connected to Slack team {} ({}) with username {}'.format( self.team_info["name"], self.domain, self.nick)) dbg("connected to {}".format(self.domain)) - if not config.background_load_all_history: - current_channel = self.eventrouter.weechat_controller.buffers.get(w.current_buffer()) - if isinstance(current_channel, SlackChannelCommon) and current_channel.team == self: - current_channel.get_history(slow_queue=True) - elif reconnect: + if config.background_load_all_history: for channel in self.channels.values(): if channel.channel_buffer: channel.get_history(slow_queue=True) + else: + current_channel = self.eventrouter.weechat_controller.buffers.get(w.current_buffer()) + if isinstance(current_channel, SlackChannelCommon) and current_channel.team == self: + current_channel.get_history(slow_queue=True) def set_disconnected(self): w.unhook(self.hook) @@ -1848,8 +1848,6 @@ class SlackChannel(SlackChannelCommon): is_open = self.is_open if hasattr(self, "is_open") else self.is_member if is_open or self.unread_count_display: self.create_buffer() - if config.background_load_all_history: - self.get_history(slow_queue=True) def set_related_server(self, team): self.team = team |