From f5782c2dcb282820f4bd9cd94ab53ff66260c4f5 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Wed, 4 May 2016 19:38:24 +0300 Subject: [PATCH] better profile saving --- src/profile.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/profile.py b/src/profile.py index e3e2dd8..1c414cc 100644 --- a/src/profile.py +++ b/src/profile.py @@ -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