decrease call to get_contact(s) function to improve speed. see #7125
This commit is contained in:
parent
63eb866b71
commit
498bcb6ccd
2 changed files with 18 additions and 11 deletions
|
@ -365,7 +365,7 @@ class LegacyContactsAPI:
|
||||||
self.is_big_brother(account, jid, accounts):
|
self.is_big_brother(account, jid, accounts):
|
||||||
# count metacontacts only once
|
# count metacontacts only once
|
||||||
continue
|
continue
|
||||||
contact = self.get_contact_with_highest_priority(account, jid)
|
contact = self._accounts[account].contacts._contacts[jid][0]
|
||||||
if _('Not in roster') in contact.groups:
|
if _('Not in roster') in contact.groups:
|
||||||
continue
|
continue
|
||||||
in_groups = False
|
in_groups = False
|
||||||
|
|
|
@ -1136,16 +1136,18 @@ class RosterWindow:
|
||||||
self.draw_contact(parent_jid, parent_account)
|
self.draw_contact(parent_jid, parent_account)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def draw_contact(self, jid, account, selected=False, focus=False):
|
def draw_contact(self, jid, account, selected=False, focus=False, contact_instances=None, contact=None):
|
||||||
"""
|
"""
|
||||||
Draw the correct state image, name BUT not avatar
|
Draw the correct state image, name BUT not avatar
|
||||||
"""
|
"""
|
||||||
# focus is about if the roster window has toplevel-focus or not
|
# focus is about if the roster window has toplevel-focus or not
|
||||||
# FIXME: We really need a custom cell_renderer
|
# FIXME: We really need a custom cell_renderer
|
||||||
|
|
||||||
contact_instances = gajim.contacts.get_contacts(account, jid)
|
if not contact_instances:
|
||||||
contact = gajim.contacts.get_highest_prio_contact_from_contacts(
|
contact_instances = gajim.contacts.get_contacts(account, jid)
|
||||||
contact_instances)
|
if not contact:
|
||||||
|
contact = gajim.contacts.get_highest_prio_contact_from_contacts(
|
||||||
|
contact_instances)
|
||||||
if not contact:
|
if not contact:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1308,11 +1310,11 @@ class RosterWindow:
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def draw_all_pep_types(self, jid, account):
|
def draw_all_pep_types(self, jid, account, contact=None):
|
||||||
for pep_type in self._pep_type_to_model_column:
|
for pep_type in self._pep_type_to_model_column:
|
||||||
self.draw_pep(jid, account, pep_type)
|
self.draw_pep(jid, account, pep_type, contact=contact)
|
||||||
|
|
||||||
def draw_pep(self, jid, account, pep_type):
|
def draw_pep(self, jid, account, pep_type, contact=None):
|
||||||
if pep_type not in self._pep_type_to_model_column:
|
if pep_type not in self._pep_type_to_model_column:
|
||||||
return
|
return
|
||||||
if not self._is_pep_shown_in_roster(pep_type):
|
if not self._is_pep_shown_in_roster(pep_type):
|
||||||
|
@ -1322,7 +1324,8 @@ class RosterWindow:
|
||||||
iters = self._get_contact_iter(jid, account, model=self.model)
|
iters = self._get_contact_iter(jid, account, model=self.model)
|
||||||
if not iters:
|
if not iters:
|
||||||
return
|
return
|
||||||
contact = gajim.contacts.get_contact(account, jid)
|
if not contact:
|
||||||
|
contact = gajim.contacts.get_contact(account, jid)
|
||||||
if pep_type in contact.pep:
|
if pep_type in contact.pep:
|
||||||
pixbuf = contact.pep[pep_type].asPixbufIcon()
|
pixbuf = contact.pep[pep_type].asPixbufIcon()
|
||||||
else:
|
else:
|
||||||
|
@ -1345,8 +1348,12 @@ class RosterWindow:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def draw_completely(self, jid, account):
|
def draw_completely(self, jid, account):
|
||||||
self.draw_contact(jid, account)
|
contact_instances = gajim.contacts.get_contacts(account, jid)
|
||||||
self.draw_all_pep_types(jid, account)
|
contact = gajim.contacts.get_highest_prio_contact_from_contacts(
|
||||||
|
contact_instances)
|
||||||
|
self.draw_contact(jid, account, contact_instances=contact_instances,
|
||||||
|
contact=contact)
|
||||||
|
self.draw_all_pep_types(jid, account, contact=contact)
|
||||||
self.draw_avatar(jid, account)
|
self.draw_avatar(jid, account)
|
||||||
|
|
||||||
def adjust_and_draw_contact_context(self, jid, account):
|
def adjust_and_draw_contact_context(self, jid, account):
|
||||||
|
|
Loading…
Add table
Reference in a new issue