Open new chats when we don't have one yet

Set notification icon properly
develop
knotteye 2021-04-25 16:53:38 -05:00
parent 26e904b5e9
commit 2ede34c207
1 changed files with 19 additions and 3 deletions

View File

@ -59,6 +59,9 @@ class App(QMainWindow):
self.setWindowIcon(QIcon(QPixmap(ICON_PATH))) 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) 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._exit = False
self.totpReady = False self.totpReady = False
self.Err = QErrorMessage() self.Err = QErrorMessage()
@ -455,17 +458,30 @@ class App(QMainWindow):
def handlePleromaEvent(self, acct, event): def handlePleromaEvent(self, acct, event):
if event['event'] == 'pleroma:chat_update': if event['event'] == 'pleroma:chat_update':
payload = json.loads(event['payload']) payload = json.loads(event['payload'])
tmp = 0 tmp = -1
for ind in range(0, self.tabs.count()): for ind in range(0, self.tabs.count()):
if self.tabs.widget(ind).acct == payload['account']['acct']: if self.tabs.widget(ind).acct == payload['account']['acct']:
self._eventloop.call_soon_threadsafe(self.tabs.widget(ind).addMessage, payload['last_message']) self._eventloop.call_soon_threadsafe(self.tabs.widget(ind).addMessage, payload['last_message'])
tmp = ind 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 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(): if self.sendNotificationsAction.isChecked():
CallThread(self.makeNotification, None, payload['last_message']['content'], payload['account']['acct'], payload['account']['avatar_static']).start() CallThread(self.makeNotification, None, payload['last_message']['content'], payload['account']['acct'], payload['account']['avatar_static']).start()
app.alert(self, 0) 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): def makeNotification(self, content, user, url):
path = getPic(url) path = getPic(url)