correctly change the resource of a control. Fixes #5261
This commit is contained in:
parent
949dbe6e38
commit
651e801334
|
@ -1433,6 +1433,19 @@ class ChatControl(ChatControlBase):
|
|||
else:
|
||||
self._tune_image.hide()
|
||||
|
||||
def change_resource(self, resource):
|
||||
old_full_jid = self.get_full_jid()
|
||||
self.resource = resource
|
||||
new_full_jid = self.get_full_jid()
|
||||
# update gajim.last_message_time
|
||||
if old_full_jid in gajim.last_message_time[self.account]:
|
||||
gajim.last_message_time[self.account][new_full_jid] = \
|
||||
gajim.last_message_time[self.account][old_full_jid]
|
||||
# update events
|
||||
gajim.events.change_jid(self.account, old_full_jid, new_full_jid)
|
||||
# update MessageWindow._controls
|
||||
self.parent_win.change_jid(self.account, old_full_jid, new_full_jid)
|
||||
|
||||
def on_avatar_eventbox_enter_notify_event(self, widget, event):
|
||||
'''
|
||||
we enter the eventbox area so we under conditions add a timeout
|
||||
|
|
|
@ -158,6 +158,15 @@ class MessageWindow(object):
|
|||
if self.account == old_name:
|
||||
self.account = new_name
|
||||
|
||||
def change_jid(self, account, old_jid, new_jid):
|
||||
''' call then when the full jid of a contral change'''
|
||||
if account not in self._controls:
|
||||
return
|
||||
if old_jid not in self._controls[account]:
|
||||
return
|
||||
self._controls[account][new_jid] = self._controls[account][old_jid]
|
||||
del self._controls[account][old_jid]
|
||||
|
||||
def get_num_controls(self):
|
||||
return sum(len(d) for d in self._controls.values())
|
||||
|
||||
|
|
|
@ -88,8 +88,8 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
|||
subject = msg.getSubject()
|
||||
if self.jid != full_jid_with_resource:
|
||||
self.resource = gajim.get_nick_from_fjid(full_jid_with_resource)
|
||||
if self.control:
|
||||
self.control.resource = self.resource
|
||||
if self.control and self.control.resource:
|
||||
self.control.change_resource(self.resource)
|
||||
|
||||
if not msg_type or msg_type not in ('chat', 'groupchat', 'error'):
|
||||
msg_type = 'normal'
|
||||
|
|
Loading…
Reference in New Issue