aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2017-11-20 16:40:15 +0000
committerAlyssa Ross <hi@alyssa.is>2017-11-20 16:40:15 +0000
commitdd20dde884e2153da36f2d4253614ab053c6cbe4 (patch)
treef4ecec5059f414340710c94f68a67a594cec66fe /wee_slack.py
parent5c4886dc95e654a88ba1b27ab93f82ea1bc98af5 (diff)
downloadwee-slack-dd20dde884e2153da36f2d4253614ab053c6cbe4.tar.gz
Refactor check_should_open
Make the method a bit easier to follow, and don't use exceptions for flow control.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 03e1748..8a50b87 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1244,22 +1244,17 @@ class SlackChannel(object):
# self.create_buffer()
def check_should_open(self, force=False):
- try:
- if self.is_archived:
- return
- except:
- pass
+ if hasattr(self, "is_archived") and self.is_archived:
+ return
+
if force:
self.create_buffer()
- else:
- for reason in ["is_member", "is_open", "unread_count_display"]:
- try:
- if eval("self." + reason):
- self.create_buffer()
- if config.background_load_all_history:
- self.get_history(slow_queue=True)
- except:
- pass
+ return
+
+ if (hasattr(self, "is_member") and self.is_member) or self.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