This commit is contained in:
ingvar1995 2016-06-23 12:21:26 +03:00
parent 55f13cbfd1
commit 190877f5b9
2 changed files with 12 additions and 10 deletions

View file

@ -75,7 +75,7 @@ class Friend(contact.Contact):
return list(map(lambda x: x.get_data(), list(messages[-self._unsaved_messages:]))) if self._unsaved_messages else [] return list(map(lambda x: x.get_data(), list(messages[-self._unsaved_messages:]))) if self._unsaved_messages else []
def get_corr(self): def get_corr(self):
return list(self._corr[:]) return self._corr[:]
def append_message(self, message): def append_message(self, message):
""" """

View file

@ -50,7 +50,7 @@ class Profile(contact.Contact, Singleton):
if not self._history.friend_exists_in_db(tox_id): if not self._history.friend_exists_in_db(tox_id):
self._history.add_friend_to_db(tox_id) self._history.add_friend_to_db(tox_id)
try: try:
alias = filter(lambda x: x[0] == tox_id, aliases)[0][1] alias = list(filter(lambda x: x[0] == tox_id, aliases))[0][1]
except: except:
alias = '' alias = ''
item = self.create_friend_item() item = self.create_friend_item()
@ -225,7 +225,7 @@ class Profile(contact.Contact, Singleton):
self._screen.account_avatar.setPixmap(pixmap.scaled(64, 64, QtCore.Qt.KeepAspectRatio)) self._screen.account_avatar.setPixmap(pixmap.scaled(64, 64, QtCore.Qt.KeepAspectRatio))
self._screen.account_avatar.repaint() # comment? self._screen.account_avatar.repaint() # comment?
except Exception as ex: # no friend found. ignore except Exception as ex: # no friend found. ignore
log('Incorrect friend value: ' + str(value)) log('Friend value: ' + str(value))
log('Error: ' + str(ex)) log('Error: ' + str(ex))
raise raise
@ -331,6 +331,7 @@ class Profile(contact.Contact, Singleton):
try: try:
for message in messages: for message in messages:
self.split_and_send(friend_number, message.get_data()[-1], message.get_data()[0].encode('utf-8')) self.split_and_send(friend_number, message.get_data()[-1], message.get_data()[0].encode('utf-8'))
friend.inc_receipts()
except: except:
pass pass
@ -561,7 +562,7 @@ class Profile(contact.Contact, Singleton):
Set new alias for friend Set new alias for friend
""" """
friend = self._friends[num] friend = self._friends[num]
name = friend.name.encode('utf-8') name = friend.name
dialog = QtGui.QApplication.translate('MainWindow', dialog = QtGui.QApplication.translate('MainWindow',
"Enter new alias for friend {} or leave empty to use friend's name:", "Enter new alias for friend {} or leave empty to use friend's name:",
None, QtGui.QApplication.UnicodeUTF8) None, QtGui.QApplication.UnicodeUTF8)
@ -578,23 +579,24 @@ class Profile(contact.Contact, Singleton):
settings = Settings.get_instance() settings = Settings.get_instance()
aliases = settings['friends_aliases'] aliases = settings['friends_aliases']
if text: if text:
friend.name = text.encode('utf-8') friend.name = bytes(text, 'utf-8')
try: try:
index = map(lambda x: x[0], aliases).index(friend.tox_id) index = list(map(lambda x: x[0], aliases)).index(friend.tox_id)
aliases[index] = (friend.tox_id, text) aliases[index] = (friend.tox_id, text)
except: except:
aliases.append((friend.tox_id, text)) aliases.append((friend.tox_id, text))
friend.set_alias(text) friend.set_alias(text)
else: # use default name else: # use default name
friend.name = self._tox.friend_get_name(friend.number).encode('utf-8') friend.name = bytes(self._tox.friend_get_name(friend.number), 'utf-8')
friend.set_alias('') friend.set_alias('')
try: try:
index = map(lambda x: x[0], aliases).index(friend.tox_id) index = list(map(lambda x: x[0], aliases)).index(friend.tox_id)
del aliases[index] del aliases[index]
except: except:
pass pass
settings.save() settings.save()
self.set_active() if num == self.get_active_number():
self.update()
def friend_public_key(self, num): def friend_public_key(self, num):
return self._friends[num].tox_id return self._friends[num].tox_id
@ -607,7 +609,7 @@ class Profile(contact.Contact, Singleton):
friend = self._friends[num] friend = self._friends[num]
settings = Settings.get_instance() settings = Settings.get_instance()
try: try:
index = map(lambda x: x[0], settings['friends_aliases']).index(friend.tox_id) index = list(map(lambda x: x[0], settings['friends_aliases'])).index(friend.tox_id)
del settings['friends_aliases'][index] del settings['friends_aliases'][index]
except: except:
pass pass