From 0cfb8efefa877b7e1cf32c32a15b4875dfeb736a Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Fri, 3 Mar 2017 22:09:45 +0300 Subject: [PATCH] reconnection fixes --- toxygen/contact.py | 2 +- toxygen/profile.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/toxygen/contact.py b/toxygen/contact.py index 6a09f3f..0a9a1aa 100644 --- a/toxygen/contact.py +++ b/toxygen/contact.py @@ -193,7 +193,7 @@ class Contact(basecontact.BaseContact): if not self._search_index: return None for i in range(self._search_index + 1, 0): - if type(self._corr[i]) is not TextMessage: + if self._corr[i].get_type() > 1: continue message = self._corr[i].get_data()[0] if re.search(self._search_string, message, re.IGNORECASE) is not None: diff --git a/toxygen/profile.py b/toxygen/profile.py index c4df1a7..84180dc 100644 --- a/toxygen/profile.py +++ b/toxygen/profile.py @@ -41,6 +41,7 @@ class Profile(basecontact.BaseContact, Singleton): self._call = calls.AV(tox.AV) # object with data about calls self._incoming_calls = set() self._load_history = True + self._waiting_for_reconnection = False self._factory = items_factory.ItemsFactory(self._screen.friends_list, self._messages) settings = Settings.get_instance() self._sorting = settings['sorting'] @@ -87,7 +88,7 @@ class Profile(basecontact.BaseContact, Singleton): if status is not None: self._tox.self_set_status(status) else: - QtCore.QTimer.singleShot(45000, self.reconnect) + QtCore.QTimer.singleShot(50000, self.reconnect) def set_name(self, value): if self.name == value: @@ -855,9 +856,13 @@ class Profile(basecontact.BaseContact, Singleton): self.update_filtration() def reconnect(self): + if self._waiting_for_reconnection: + return + self._waiting_for_reconnection = False if self.status is None or all(list(map(lambda x: x.status is None, self._contacts))) and len(self._contacts): + self._waiting_for_reconnection = True self.reset(self._screen.reset) - QtCore.QTimer.singleShot(45000, self.reconnect) + QtCore.QTimer.singleShot(50000, self.reconnect) def close(self): for friend in self._contacts: