Commit ca682cf2 authored by mathieui's avatar mathieui
Browse files

Muctab: Only search for matching colors on user join

this call is actually quite expensive, so it will help in specific cases
where we receive a lot of presence stanzas (e.g. a netsplit in an irc
gateway, or a +vvvvvvvvvvvvvvvvvvvvvvvvv, etc) that are not joins
parent 5f0c0fbb
...@@ -1098,13 +1098,13 @@ class MucTab(ChatTab): ...@@ -1098,13 +1098,13 @@ class MucTab(ChatTab):
jid = presence['muc']['jid'] jid = presence['muc']['jid']
typ = presence['type'] typ = presence['type']
deterministic = config.get_by_tabname('deterministic_nick_colors', self.name) deterministic = config.get_by_tabname('deterministic_nick_colors', self.name)
color = self.search_for_color(from_nick)
if not self.joined: # user in the room BEFORE us. if not self.joined: # user in the room BEFORE us.
# ignore redondant presence message, see bug #1509 # ignore redondant presence message, see bug #1509
if (from_nick not in [user.nick for user in self.users] if (from_nick not in [user.nick for user in self.users]
and typ != "unavailable"): and typ != "unavailable"):
user_color = self.search_for_color(from_nick)
new_user = User(from_nick, affiliation, show, new_user = User(from_nick, affiliation, show,
status, role, jid, deterministic, color) status, role, jid, deterministic, user_color)
bisect.insort_left(self.users, new_user) bisect.insort_left(self.users, new_user)
self.core.events.trigger('muc_join', presence, self) self.core.events.trigger('muc_join', presence, self)
if '110' in status_codes or self.own_nick == from_nick: if '110' in status_codes or self.own_nick == from_nick:
...@@ -1183,9 +1183,10 @@ class MucTab(ChatTab): ...@@ -1183,9 +1183,10 @@ class MucTab(ChatTab):
user = self.get_user_by_name(from_nick) user = self.get_user_by_name(from_nick)
# New user # New user
if not user: if not user:
user_color = self.search_for_color(from_nick)
self.core.events.trigger('muc_join', presence, self) self.core.events.trigger('muc_join', presence, self)
self.on_user_join(from_nick, affiliation, show, status, role, self.on_user_join(from_nick, affiliation, show, status, role,
jid, color) jid, user_color)
# nick change # nick change
elif change_nick: elif change_nick:
self.core.events.trigger('muc_nickchange', presence, self) self.core.events.trigger('muc_nickchange', presence, self)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment