aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorRyan Huber <rhuber@gmail.com>2017-01-24 12:16:08 -0800
committerRyan Huber <rhuber@gmail.com>2017-01-24 12:16:08 -0800
commit4923f6c2d05d7db0263650a23e100aa75134e11a (patch)
treebe9c2e75473c9ac67a32175346419b3ca3061bbc /wee_slack.py
parentcc536faff7235c2745eee30069fff64cab24ca47 (diff)
downloadwee-slack-4923f6c2d05d7db0263650a23e100aa75134e11a.tar.gz
don't load channel history until opening the channel
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 13e285b..4bdb305 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -162,6 +162,7 @@ class SlackServer(object):
self.message_buffer = {}
self.ping_hook = None
self.alias = None
+ self.got_history = False
self.identifier = None
self.connect_to_slack()
@@ -357,8 +358,8 @@ class SlackServer(object):
if self.channels.find(item) is not None:
self.channels.find(item).muted = True
- for item in self.channels:
- item.get_history()
+ #for item in self.channels:
+ # item.get_history()
def buffer_prnt(self, message='no message', user="SYSTEM", backlog=False):
message = message.encode('ascii', 'ignore')
@@ -427,6 +428,7 @@ class Channel(object):
self.scrolling = False
self.last_active_user = None
self.muted = False
+ self.got_history = False
if active:
self.create_buffer()
self.attach_buffer()
@@ -819,6 +821,7 @@ class Channel(object):
async_slack_api_request(self.server.domain, self.server.token, SLACK_API_TRANSLATOR[self.type]["history"], {"channel": self.identifier, "oldest": self.last_received, "count": BACKLOG_SIZE})
else:
async_slack_api_request(self.server.domain, self.server.token, SLACK_API_TRANSLATOR[self.type]["history"], {"channel": self.identifier, "count": BACKLOG_SIZE})
+ self.got_history = True
class GroupChannel(Channel):
@@ -2119,6 +2122,10 @@ def buffer_switch_cb(signal, sig_type, data):
if channels.find(previous_buffer):
channels.find(previous_buffer).mark_read()
+ new_channel = channels.find(data)
+ if new_channel:
+ if new_channel.got_history == False:
+ new_channel.get_history()
# channel_name = current_buffer_name()
previous_buffer = data
return w.WEECHAT_RC_OK