From 5b3a013766635a5d46f39c5c93a949ad769d4e69 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Sun, 15 Sep 2019 09:58:22 -0500 Subject: [PATCH] Update online friends buffer even if chat notifications are disabled --- changelog.md | 1 + src/controller/mainController.py | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/changelog.md b/changelog.md index c5bf9fc..4468a6b 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,7 @@ ### bugfixes +* Fixed an error that was causing socializer to not update the "Online friends" buffer if chat notifications were disabled. * Fixed an error that was making Socializer unable to attach audio files from the computer, if the file does not include correct ID3 TAGS. * Fixed a traceback that was being logged when attempting to load an image but cancel the dialog for attaching it. * Fixed an error that was making Socializer to fail when loading the newsfeed buffer, thus not loading any other buffers. This error was caused due to VK sending a new object type (undocumented for now) representing push subscriptions. The item is ignored by Socializer so it will not break the newsfeed buffer anymore. diff --git a/src/controller/mainController.py b/src/controller/mainController.py index c3e2cda..afd6e98 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -443,15 +443,14 @@ class Controller(object): p = presenters.userProfilePresenter(session=self.session, user_id=person, view=views.userProfileDialog(), interactor=interactors.userProfileInteractor()) def user_online(self, event): - """ Sends a notification of an user connecting to VK. + """ Add user to the online buffer and Send a notification of an user connecting to VK. @ event vk_api.longpoll.event object: The event sent by the vk_api's longPoll module. """ - if self.session.settings["chat"]["notify_online"] == False: - return - user_name = self.session.get_user(event.user_id) - msg = _("{user1_nom} is online.").format(**user_name) - sound = "friend_online.ogg" - self.notify(msg, sound, self.session.settings["chat"]["notifications"]) + if self.session.settings["chat"]["notify_online"] == True: + user_name = self.session.get_user(event.user_id) + msg = _("{user1_nom} is online.").format(**user_name) + sound = "friend_online.ogg" + self.notify(msg, sound, self.session.settings["chat"]["notifications"]) online_buffer = self.search("online_friends") user = None for i in self.session.db["friends_"]["items"]: @@ -465,15 +464,14 @@ class Controller(object): wx.CallAfter(online_buffer.add_person, user) def user_offline(self, event): - """ Sends a notification of an user logging off in VK. + """ Remove user from the online buffer and Send a notification of an user logging off in VK. @ event vk_api.longpoll.event object: The event sent by the vk_api's longPoll module. """ - if self.session.settings["chat"]["notify_offline"] == False: - return - user_name = self.session.get_user(event.user_id) - msg = _("{user1_nom} is offline.").format(**user_name) - sound = "friend_offline.ogg" - self.notify(msg, sound, self.session.settings["chat"]["notifications"]) + if self.session.settings["chat"]["notify_offline"] == True: + user_name = self.session.get_user(event.user_id) + msg = _("{user1_nom} is offline.").format(**user_name) + sound = "friend_offline.ogg" + self.notify(msg, sound, self.session.settings["chat"]["notifications"]) online_friends = self.search("online_friends") wx.CallAfter(online_friends.remove_person, event.user_id)