quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
This commit is contained in:
parent
1a03845539
commit
78f14091b1
1 changed files with 96 additions and 54 deletions
|
|
@ -534,6 +534,7 @@ class QuickApp(object):
|
|||
chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
|
||||
chat_widget.setUserNick(unicode(user_nick))
|
||||
self.contact_lists[profile].setSpecial(room_jid, C.CONTACT_SPECIAL_GROUP)
|
||||
chat_widget.update()
|
||||
|
||||
def roomLeftHandler(self, room_jid_s, profile):
|
||||
"""Called when a MUC room is left"""
|
||||
|
|
@ -579,16 +580,20 @@ class QuickApp(object):
|
|||
@param state (unicode): new state
|
||||
@param profile (unicode): current profile
|
||||
"""
|
||||
log.debug(_(u"Received new chat state {} from {} [{}]").format(state, from_jid_s, profile))
|
||||
from_jid = jid.JID(from_jid_s) if from_jid_s != C.ENTITY_ALL else C.ENTITY_ALL
|
||||
contact_list = self.contact_lists[profile]
|
||||
for widget in self.widgets.getWidgets(quick_chat.QuickChat):
|
||||
if profile != widget.profile:
|
||||
continue
|
||||
to_display = C.USER_CHAT_STATES[state] if (state and widget.type == C.CHAT_GROUP) else state
|
||||
if widget.type == C.CHAT_GROUP and from_jid_s == C.ENTITY_ALL:
|
||||
for occupant in [jid.newResource(widget.target, nick) for nick in widget.occupants]:
|
||||
widget.updateEntityState(occupant, 'chat_state', to_display)
|
||||
contact_list.setCache(occupant, 'chat_state', to_display)
|
||||
widget.update(occupant)
|
||||
elif from_jid.bare == widget.target.bare: # roster contact or MUC occupant
|
||||
widget.updateEntityState(from_jid, 'chat_state', to_display)
|
||||
contact_list.setCache(from_jid, 'chat_state', to_display)
|
||||
widget.update(from_jid)
|
||||
|
||||
def personalEventHandler(self, sender, event_type, data):
|
||||
"""Called when a PEP event is received.
|
||||
|
|
|
|||
Loading…
Reference in a new issue