From 9e7e9b9012ee10e4b5573002f3b3b790f7a1566a Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sat, 24 Dec 2016 14:20:58 +0300 Subject: [PATCH] incorrect contacts list update fixed --- toxygen/basecontact.py | 2 +- toxygen/profile.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/toxygen/basecontact.py b/toxygen/basecontact.py index a7bb63f..0963f2a 100644 --- a/toxygen/basecontact.py +++ b/toxygen/basecontact.py @@ -86,7 +86,7 @@ class BaseContact: """ avatar_path = '{}.png'.format(self._tox_id[:TOX_PUBLIC_KEY_SIZE * 2]) os.chdir(ProfileHelper.get_path() + 'avatars/') - if not os.path.isfile(avatar_path): # load default image + if not os.path.isfile(avatar_path) or not os.path.getsize(avatar_path): # load default image avatar_path = 'avatar.png' os.chdir(curr_directory() + '/images/') width = self._widget.avatar_label.width() diff --git a/toxygen/profile.py b/toxygen/profile.py index aa16aba..ad1bcda 100644 --- a/toxygen/profile.py +++ b/toxygen/profile.py @@ -127,6 +127,7 @@ class Profile(basecontact.BaseContact, Singleton): """ filter_str = filter_str.lower() settings = Settings.get_instance() + number = self.get_active_number() if sorting > 1: if sorting & 2: self._contacts = sorted(self._contacts, key=lambda x: int(x.status is not None), reverse=True) @@ -162,6 +163,7 @@ class Profile(basecontact.BaseContact, Singleton): self._sorting, self._filter_string = sorting, filter_str settings['sorting'] = self._sorting settings.save() + self.set_active_by_number(number) def update_filtration(self): """ @@ -270,12 +272,17 @@ class Profile(basecontact.BaseContact, Singleton): pixmap = QtGui.QPixmap(avatar_path) self._screen.account_avatar.setPixmap(pixmap.scaled(64, 64, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)) - self.update_filtration() except Exception as ex: # no friend found. ignore log('Friend value: ' + str(value)) log('Error in set active: ' + str(ex)) raise + def set_active_by_number(self, number): + for i in range(len(self._contacts)): + if self._contacts[i].number == number: + self._active_friend = i + break + active_friend = property(get_active, set_active) def get_last_message(self):