From 820b5a02534e2ce75382c27a90a6eb75ab7ad35a Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sat, 21 Jul 2018 17:16:01 +0300 Subject: [PATCH] reconnection - clear peers list --- toxygen/contacts/group_chat.py | 3 +++ toxygen/groups/groups_service.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/toxygen/contacts/group_chat.py b/toxygen/contacts/group_chat.py index 57d471a..b18fb14 100644 --- a/toxygen/contacts/group_chat.py +++ b/toxygen/contacts/group_chat.py @@ -51,6 +51,9 @@ class GroupChat(contact.Contact, ToxSave): return peers[0] + def remove_all_peers_except_self(self): + self._peers = self._peers[:1] + def get_peers(self): return self._peers[:] diff --git a/toxygen/groups/groups_service.py b/toxygen/groups/groups_service.py index 69f8ec1..2c0d4c3 100644 --- a/toxygen/groups/groups_service.py +++ b/toxygen/groups/groups_service.py @@ -47,11 +47,13 @@ class GroupsService(tox_save.ToxSave): self._tox.group_disconnect(group_number) group = self._get_group(group_number) group.status = None + self._clear_peers_list(group) def reconnect_to_group(self, group_number): self._tox.group_reconnect(group_number) group = self._get_group(group_number) group.status = constants.TOX_USER_STATUS['NONE'] + self._clear_peers_list(group) # ----------------------------------------------------------------------------------------------------------------- # Group invites @@ -102,3 +104,7 @@ class GroupsService(tox_save.ToxSave): def _get_all_groups(self): return self._contacts_provider.get_all_groups() + + def _clear_peers_list(self, group): + group.remove_all_peers_except_self() + self.generate_peers_list()