comparison frontends/src/quick_frontend/quick_contact_list.py @ 2082:e8cb9cc09485

quick frontend(contact_list): avoid crash when resource in cache has not priority
author Goffi <goffi@goffi.org>
date Sun, 02 Oct 2016 13:46:29 +0200
parents f3167c873e7b
children 4d9aeae5d9d0
comparison
equal deleted inserted replaced
2081:2265d9df4cfb 2082:e8cb9cc09485
499 resource_data[C.PRESENCE_SHOW] = show 499 resource_data[C.PRESENCE_SHOW] = show
500 resource_data[C.PRESENCE_PRIORITY] = int(priority) 500 resource_data[C.PRESENCE_PRIORITY] = int(priority)
501 resource_data[C.PRESENCE_STATUSES] = statuses 501 resource_data[C.PRESENCE_STATUSES] = statuses
502 502
503 if entity.bare not in self._specials: 503 if entity.bare not in self._specials:
504 priority_resource = max(resources_data, key=lambda res: resources_data[res][C.PRESENCE_PRIORITY]) 504 # we may have resources with no priority
505 # (when a cached value is added for a not connected resource)
506 priority_resource = max(resources_data, key=lambda res: resources_data[res].get(C.PRESENCE_PRIORITY, -2**32))
505 cache[C.CONTACT_MAIN_RESOURCE] = priority_resource 507 cache[C.CONTACT_MAIN_RESOURCE] = priority_resource
506 self.update([entity], C.UPDATE_MODIFY, self.profile) 508 self.update([entity], C.UPDATE_MODIFY, self.profile)
507 509
508 def onNickUpdate(self, entity, new_nick, profile): 510 def onNickUpdate(self, entity, new_nick, profile):
509 """Update entity's nick 511 """Update entity's nick