Fix bug that prevented avatars to be shown in groupchats. Bug was due to a wrong re-use of a local variable (local variabes are evil :-).
Additionally: Remove some appreviations and unneeded local variables.
This commit is contained in:
parent
76013a044b
commit
ca382031eb
|
@ -130,7 +130,7 @@ class PrivateChatControl(ChatControl):
|
||||||
COMMAND_HOST = PrivateChatCommands
|
COMMAND_HOST = PrivateChatCommands
|
||||||
|
|
||||||
def __init__(self, parent_win, gc_contact, contact, account, session):
|
def __init__(self, parent_win, gc_contact, contact, account, session):
|
||||||
room_jid = contact.jid.split('/')[0]
|
room_jid = gc_contact.room_jid
|
||||||
room_ctrl = gajim.interface.msg_win_mgr.get_gc_control(room_jid, account)
|
room_ctrl = gajim.interface.msg_win_mgr.get_gc_control(room_jid, account)
|
||||||
if room_jid in gajim.interface.minimized_controls[account]:
|
if room_jid in gajim.interface.minimized_controls[account]:
|
||||||
room_ctrl = gajim.interface.minimized_controls[account][room_jid]
|
room_ctrl = gajim.interface.minimized_controls[account][room_jid]
|
||||||
|
|
|
@ -609,8 +609,7 @@ def get_avatar_pixbuf_from_cache(fjid, use_local=True):
|
||||||
# don't show avatar for the transport itself
|
# don't show avatar for the transport itself
|
||||||
return None
|
return None
|
||||||
|
|
||||||
room, nick = gajim.get_room_and_nick_from_fjid(jid)
|
if any(jid in gajim.contacts.get_gc_list(acc) for acc in gajim.connections):
|
||||||
if any(room in gajim.contacts.get_gc_list(acc) for acc in gajim.connections):
|
|
||||||
is_groupchat_contact = True
|
is_groupchat_contact = True
|
||||||
else:
|
else:
|
||||||
is_groupchat_contact = False
|
is_groupchat_contact = False
|
||||||
|
|
|
@ -2640,40 +2640,36 @@ class Interface:
|
||||||
mw.new_tab(gc_control)
|
mw.new_tab(gc_control)
|
||||||
|
|
||||||
def new_private_chat(self, gc_contact, account, session=None):
|
def new_private_chat(self, gc_contact, account, session=None):
|
||||||
contact = gc_contact.as_contact()
|
|
||||||
type_ = message_control.TYPE_PM
|
|
||||||
fjid = gc_contact.room_jid + '/' + gc_contact.name
|
|
||||||
|
|
||||||
conn = gajim.connections[account]
|
conn = gajim.connections[account]
|
||||||
|
if not session and gc_contact.get_full_jid() in conn.sessions:
|
||||||
if not session and fjid in conn.sessions:
|
sessions = [s for s in conn.sessions[gc_contact.get_full_jid()].values()
|
||||||
sessions = [s for s in conn.sessions[fjid].values() if isinstance(s, ChatControlSession)]
|
if isinstance(s, ChatControlSession)]
|
||||||
|
|
||||||
# look for an existing session with a chat control
|
# look for an existing session with a chat control
|
||||||
for s in sessions:
|
for s in sessions:
|
||||||
if s.control:
|
if s.control:
|
||||||
session = s
|
session = s
|
||||||
break
|
break
|
||||||
|
|
||||||
if not session and not len(sessions) == 0:
|
if not session and not len(sessions) == 0:
|
||||||
# there are no sessions with chat controls, just take the first one
|
# there are no sessions with chat controls, just take the first one
|
||||||
session = sessions[0]
|
session = sessions[0]
|
||||||
|
|
||||||
if not session:
|
if not session:
|
||||||
# couldn't find an existing ChatControlSession, just make a new one
|
# couldn't find an existing ChatControlSession, just make a new one
|
||||||
|
session = conn.make_new_session(gc_contact.get_full_jid(), None, 'pm')
|
||||||
|
|
||||||
session = conn.make_new_session(fjid, None, 'pm')
|
contact = gc_contact.as_contact()
|
||||||
|
|
||||||
if not session.control:
|
if not session.control:
|
||||||
mw = self.msg_win_mgr.get_window(fjid, account)
|
message_window = self.msg_win_mgr.get_window(gc_contact.get_full_jid(),
|
||||||
if not mw:
|
account)
|
||||||
mw = self.msg_win_mgr.create_window(contact, account, type_)
|
if not message_window:
|
||||||
|
message_window = self.msg_win_mgr.create_window(contact, account,
|
||||||
|
message_control.TYPE_PM)
|
||||||
|
|
||||||
session.control = PrivateChatControl(mw, gc_contact, contact, account,
|
session.control = PrivateChatControl(message_window, gc_contact,
|
||||||
session)
|
contact, account, session)
|
||||||
mw.new_tab(session.control)
|
message_window.new_tab(session.control)
|
||||||
|
|
||||||
if len(gajim.events.get_events(account, fjid)):
|
if gajim.events.get_events(account, gc_contact.get_full_jid()):
|
||||||
# We call this here to avoid race conditions with widget validation
|
# We call this here to avoid race conditions with widget validation
|
||||||
session.control.read_queue()
|
session.control.read_queue()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue