From 2ede34c2070acf0c89e71abd8a9c97ed8384e235 Mon Sep 17 00:00:00 2001 From: knotteye Date: Sun, 25 Apr 2021 16:53:38 -0500 Subject: [PATCH] Open new chats when we don't have one yet Set notification icon properly --- plchat.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/plchat.py b/plchat.py index 06d4f1e..b77836e 100644 --- a/plchat.py +++ b/plchat.py @@ -59,6 +59,9 @@ class App(QMainWindow): self.setWindowIcon(QIcon(QPixmap(ICON_PATH))) self.setGeometry(self.settings.value('left', type=int) or 10, self.settings.value('top', type=int) or 10, self.settings.value('width', type=int) or 640, self.settings.value('height', type=int) or 480) + if self.settings.value('silenceNotifications', type=bool): + Notification._notification_audio = None + self._exit = False self.totpReady = False self.Err = QErrorMessage() @@ -455,17 +458,30 @@ class App(QMainWindow): def handlePleromaEvent(self, acct, event): if event['event'] == 'pleroma:chat_update': payload = json.loads(event['payload']) - tmp = 0 + tmp = -1 for ind in range(0, self.tabs.count()): if self.tabs.widget(ind).acct == payload['account']['acct']: self._eventloop.call_soon_threadsafe(self.tabs.widget(ind).addMessage, payload['last_message']) tmp = ind - #self.tabs.widget(ind).addMessage(payload['last_message']) if payload['last_message']['account_id'] != acct.flakeid and (not self.hasFocus() or payload['account']['acct'] != self.tabs.widget(self.tabs.currentIndex()).acct): if self.sendNotificationsAction.isChecked(): CallThread(self.makeNotification, None, payload['last_message']['content'], payload['account']['acct'], payload['account']['avatar_static']).start() app.alert(self, 0) - self._eventloop.call_soon_threadsafe(self.setUrgent, tmp) + if tmp > 0: + self._eventloop.call_soon_threadsafe(self.setUrgent, tmp) + else: + u, i = ex.getCurrentAcc() + tmp = self.tabs.count() + closedList = self.settings.value('closed'+u+i, type=list) or [] + for ind in range(0,(len(closedList))): + if closedList[ind] == payload['account']['acct']: + del closedList[ind] + break + self.settings.setValue('closed'+u+i, closedList) + self._eventloop.call_soon_threadsafe(self.populateChats, payload) + while self.tabs.tabIcon(tmp).isNull(): + time.sleep(0.3) + self._eventloop.call_soon_threadsafe(self.setUrgent, tmp) def makeNotification(self, content, user, url): path = getPic(url)