From dc12930253fc792342c5e68faaeb11e68edcfdd0 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sun, 3 Feb 2008 19:31:01 +0000 Subject: [PATCH] [sgala] nicer code. No need to change contact's status to offline when we go offline if contact is already offline. see #3718 --- src/roster_window.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/roster_window.py b/src/roster_window.py index 718b77a09..d135702bb 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -1358,22 +1358,20 @@ class RosterWindow: # name is to show in conversation window name = contact.get_shown_name() - if show in ('offline', 'error') and \ - len(gajim.events.get_events(account, contact.get_full_jid())) == 0: - if len(contact_instances) > 1: - # if multiple resources - if contact.resource != '': - name += '/' + contact.resource + if len(contact_instances) > 1: + if contact.resource != '': + name += '/' + contact.resource + if show in ('offline', 'error') and \ + len(gajim.events.get_events(account, contact.get_full_jid())) == 0: jid_with_resource = contact.jid + '/' + contact.resource - if gajim.interface.msg_win_mgr.has_window(jid_with_resource, account): + if gajim.interface.msg_win_mgr.has_window(jid_with_resource, + account): win = gajim.interface.msg_win_mgr.get_window(jid_with_resource, account) ctrl = win.get_control(jid_with_resource, account) ctrl.update_ui() win.redraw_tab(ctrl) gajim.contacts.remove_contact(account, contact) - elif len(contact_instances) > 1 and contact.resource != '': - name += '/' + contact.resource self.remove_contact(contact, account) self.add_contact_to_roster(contact.jid, account) # print status in chat window and update status/GPG image @@ -3890,10 +3888,7 @@ class RosterWindow: gajim.con_types[account] = None for jid in gajim.contacts.get_jid_list(account): lcontact = gajim.contacts.get_contacts(account, jid) - lcontact_copy = [] - for contact in lcontact: - lcontact_copy.append(contact) - for contact in lcontact_copy: + for contact in [c for c in lcontact if c.show != 'offline']: self.chg_contact_status(contact, 'offline', '', account) self.actions_menu_needs_rebuild = True self.update_status_combobox()