fix: remove notifications from OS tray when app is opened back

This commit is contained in:
Jonathan Rainville 2021-02-15 11:29:16 -05:00 committed by Iuri Matias
parent 96c2f123b4
commit 82ede94700
3 changed files with 15 additions and 3 deletions

View File

@ -42,7 +42,7 @@ StackLayout {
currentIndex: chatsModel.activeChannelIndex > -1 && chatGroupsListViewCount > 0 ? 0 : 1
property var idMap: {}
property var idMap: ({})
function addSuggestionFromMessageList(i){
const contactAddr = chatsModel.messageList.getMessageData(i, "publicKey");
@ -76,8 +76,8 @@ StackLayout {
idMap[contactAddr] = true;
}
const len2 = chatsModel.messageList.rowCount();
for (let i = 0; i < len2; i++) {
addSuggestionFromMessageList(i);
for (let f = 0; f < len2; f++) {
addSuggestionFromMessageList(f);
}
}

View File

@ -191,6 +191,7 @@ ScrollView {
message = qsTr("You have a new message")
}
currentlyHasANotification = true
if (appSettings.useOSNotifications && systemTray.supportsMessages) {
systemTray.showMessage(name,
message,

View File

@ -230,6 +230,17 @@ ApplicationWindow {
}
}
property bool currentlyHasANotification: false
onActiveChanged: {
if (active && currentlyHasANotification) {
currentlyHasANotification = false
// QML doesn't have a function to hide notifications, but this does the trick
systemTray.hide()
systemTray.show()
}
}
SystemTrayIcon {
id: systemTray
visible: true