Correctly count metacontacts in non merged accounts mode if we have metacontacts over several accounts.
This commit is contained in:
parent
215fdc964a
commit
0671e6c865
|
@ -326,8 +326,8 @@ class Contacts:
|
||||||
_('Transports') in groups:
|
_('Transports') in groups:
|
||||||
# do not count transports
|
# do not count transports
|
||||||
continue
|
continue
|
||||||
if self.has_brother(account, jid) and not \
|
if self.has_brother(account, jid, accounts) and not \
|
||||||
self.is_big_brother(account, jid):
|
self.is_big_brother(account, jid, accounts):
|
||||||
# count metacontacts only once
|
# count metacontacts only once
|
||||||
continue
|
continue
|
||||||
contact = self.get_contact_with_highest_priority(account, jid)
|
contact = self.get_contact_with_highest_priority(account, jid)
|
||||||
|
@ -402,26 +402,30 @@ class Contacts:
|
||||||
self._metacontacts_tags[account])
|
self._metacontacts_tags[account])
|
||||||
break
|
break
|
||||||
|
|
||||||
def has_brother(self, account, jid):
|
def has_brother(self, account, jid, accounts):
|
||||||
tag = self.get_metacontacts_tag(account, jid)
|
tag = self.get_metacontacts_tag(account, jid)
|
||||||
if not tag:
|
if not tag:
|
||||||
return False
|
return False
|
||||||
meta_jids = self.get_metacontacts_jids(tag)
|
meta_jids = self.get_metacontacts_jids(tag, accounts)
|
||||||
return len(meta_jids) > 1 or len(meta_jids[account]) > 1
|
return len(meta_jids) > 1 or len(meta_jids[account]) > 1
|
||||||
|
|
||||||
def is_big_brother(self, account, jid):
|
def is_big_brother(self, account, jid, accounts):
|
||||||
family = self.get_metacontacts_family(account, jid)
|
family = self.get_metacontacts_family(account, jid)
|
||||||
if family:
|
if family:
|
||||||
bb_data = self.get_metacontacts_big_brother(family)
|
nearby_family = [data for data in family
|
||||||
|
if account in accounts]
|
||||||
|
bb_data = self.get_metacontacts_big_brother(nearby_family)
|
||||||
if bb_data['jid'] == jid and bb_data['account'] == account:
|
if bb_data['jid'] == jid and bb_data['account'] == account:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_metacontacts_jids(self, tag):
|
def get_metacontacts_jids(self, tag, accounts):
|
||||||
'''Returns all jid for the given tag in the form {acct: [jid1, jid2],.}'''
|
'''Returns all jid for the given tag in the form {acct: [jid1, jid2],.}'''
|
||||||
answers = {}
|
answers = {}
|
||||||
for account in self._metacontacts_tags:
|
for account in self._metacontacts_tags:
|
||||||
if tag in self._metacontacts_tags[account]:
|
if tag in self._metacontacts_tags[account]:
|
||||||
|
if account not in accounts:
|
||||||
|
continue
|
||||||
answers[account] = []
|
answers[account] = []
|
||||||
for data in self._metacontacts_tags[account][tag]:
|
for data in self._metacontacts_tags[account][tag]:
|
||||||
answers[account].append(data['jid'])
|
answers[account].append(data['jid'])
|
||||||
|
|
|
@ -3785,7 +3785,8 @@ class RosterWindow:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Is the contact we drag a meta contact?
|
# Is the contact we drag a meta contact?
|
||||||
is_big_brother = gajim.contacts.is_big_brother(account_source, jid_source)
|
accounts = (self.regroup and gajim.contacts.get_accounts()) or account_source
|
||||||
|
is_big_brother = gajim.contacts.is_big_brother(account_source, jid_source, accounts)
|
||||||
|
|
||||||
# Contact drop on group row or between two contacts
|
# Contact drop on group row or between two contacts
|
||||||
if type_dest == 'group' or position == gtk.TREE_VIEW_DROP_BEFORE or \
|
if type_dest == 'group' or position == gtk.TREE_VIEW_DROP_BEFORE or \
|
||||||
|
|
Loading…
Reference in New Issue