incorrect contacts list update fixed

This commit is contained in:
ingvar1995 2016-12-24 14:20:58 +03:00
parent 2c4301e4f0
commit 9e7e9b9012
2 changed files with 9 additions and 2 deletions

View File

@ -86,7 +86,7 @@ class BaseContact:
""" """
avatar_path = '{}.png'.format(self._tox_id[:TOX_PUBLIC_KEY_SIZE * 2]) avatar_path = '{}.png'.format(self._tox_id[:TOX_PUBLIC_KEY_SIZE * 2])
os.chdir(ProfileHelper.get_path() + 'avatars/') 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' avatar_path = 'avatar.png'
os.chdir(curr_directory() + '/images/') os.chdir(curr_directory() + '/images/')
width = self._widget.avatar_label.width() width = self._widget.avatar_label.width()

View File

@ -127,6 +127,7 @@ class Profile(basecontact.BaseContact, Singleton):
""" """
filter_str = filter_str.lower() filter_str = filter_str.lower()
settings = Settings.get_instance() settings = Settings.get_instance()
number = self.get_active_number()
if sorting > 1: if sorting > 1:
if sorting & 2: if sorting & 2:
self._contacts = sorted(self._contacts, key=lambda x: int(x.status is not None), reverse=True) 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 self._sorting, self._filter_string = sorting, filter_str
settings['sorting'] = self._sorting settings['sorting'] = self._sorting
settings.save() settings.save()
self.set_active_by_number(number)
def update_filtration(self): def update_filtration(self):
""" """
@ -270,12 +272,17 @@ class Profile(basecontact.BaseContact, Singleton):
pixmap = QtGui.QPixmap(avatar_path) pixmap = QtGui.QPixmap(avatar_path)
self._screen.account_avatar.setPixmap(pixmap.scaled(64, 64, QtCore.Qt.KeepAspectRatio, self._screen.account_avatar.setPixmap(pixmap.scaled(64, 64, QtCore.Qt.KeepAspectRatio,
QtCore.Qt.SmoothTransformation)) QtCore.Qt.SmoothTransformation))
self.update_filtration()
except Exception as ex: # no friend found. ignore except Exception as ex: # no friend found. ignore
log('Friend value: ' + str(value)) log('Friend value: ' + str(value))
log('Error in set active: ' + str(ex)) log('Error in set active: ' + str(ex))
raise 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) active_friend = property(get_active, set_active)
def get_last_message(self): def get_last_message(self):