better profile saving

This commit is contained in:
ingvar1995 2016-05-04 19:38:24 +03:00
parent 7a5b1fc05e
commit f5782c2dcb

View file

@ -719,6 +719,8 @@ class Profile(Contact, Singleton):
self.set_active(-1)
else:
self.set_active(0)
data = self._tox.get_savedata()
ProfileHelper.save_profile(data)
def add_friend(self, tox_id):
num = self._tox.friend_add_norequest(tox_id) # num - friend number
@ -747,6 +749,8 @@ class Profile(Contact, Singleton):
try:
num = self._tox.friend_by_public_key(tox_id)
self.delete_friend(num)
data = self._tox.get_savedata()
ProfileHelper.save_profile(data)
except: # not in friend list
pass
@ -761,6 +765,8 @@ class Profile(Contact, Singleton):
s.save()
if add_to_friend_list:
self.add_friend(tox_id)
data = self._tox.get_savedata()
ProfileHelper.save_profile(data)
# -----------------------------------------------------------------------------------------------------------------
# Friend requests
@ -787,6 +793,8 @@ class Profile(Contact, Singleton):
message_getter = self._history.messages_getter(tox_id)
friend = Friend(message_getter, result, tox_id, '', item, tox_id)
self._friends.append(friend)
data = self._tox.get_savedata()
ProfileHelper.save_profile(data)
return True
except Exception as ex: # wrong data
log('Friend request failed with ' + str(ex))
@ -805,6 +813,8 @@ class Profile(Contact, Singleton):
reply = QtGui.QMessageBox.question(None, fr_req, info, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes: # accepted
self.add_friend(tox_id)
data = self._tox.get_savedata()
ProfileHelper.save_profile(data)
except Exception as ex: # something is wrong
log('Accept friend request failed! ' + str(ex))
@ -820,6 +830,7 @@ class Profile(Contact, Singleton):
for key in self._file_transfers.keys():
self._file_transfers[key].cancel()
del self._file_transfers[key]
self._call.stop()
del self._tox
self._tox = restart()
self.status = None