fix(notifs): fix linux notifications not appearing

This commit is contained in:
Jonathan Rainville 2021-11-30 12:52:34 -05:00
parent 8be841e0ac
commit 33c3f2278b
3 changed files with 47 additions and 15 deletions

View File

@ -611,6 +611,11 @@ Item {
currentlyHasANotification = true currentlyHasANotification = true
if (Qt.platform.os === "linux") {
// Linux Notifications are not implemented in Nim/C++ yet
return systemTray.showMessage(name, message, systemTray.icon.source, 4000)
}
// Note: // Note:
// Show notification should be moved to the nim side. // Show notification should be moved to the nim side.
// Left here only cause we don't have a way to deal with translations on the nim side. // Left here only cause we don't have a way to deal with translations on the nim side.

View File

@ -222,11 +222,20 @@ Item {
onMembershipRequestChanged: function (communityId, communityName, accepted) { onMembershipRequestChanged: function (communityId, communityName, accepted) {
chatColumnLayout.currentNotificationChatId = null chatColumnLayout.currentNotificationChatId = null
chatColumnLayout.currentNotificationCommunityId = communityId chatColumnLayout.currentNotificationCommunityId = communityId
root.store.chatsModelInst.showOSNotification("Status",
//% "You have been accepted into the %1 community" const title = "Status"
accepted ? qsTrId("you-have-been-accepted-into-the---1--community").arg(communityName) : const message = //% "You have been accepted into the %1 community"
//% "Your request to join the %1 community was declined" accepted ? qsTrId("you-have-been-accepted-into-the---1--community").arg(communityName) :
qsTrId("your-request-to-join-the---1--community-was-declined").arg(communityName), //% "Your request to join the %1 community was declined"
qsTrId("your-request-to-join-the---1--community-was-declined").arg(communityName)
if (Qt.platform.os === "linux") {
// Linux Notifications are not implemented in Nim/C++ yet
return systemTray.showMessage(title, message, systemTray.icon.source, 4000)
}
root.store.chatsModelInst.showOSNotification(title,
message,
accepted? Constants.osNotificationType.acceptedIntoCommunity : accepted? Constants.osNotificationType.acceptedIntoCommunity :
Constants.osNotificationType.rejectedByCommunity, Constants.osNotificationType.rejectedByCommunity,
communityId, communityId,
@ -238,10 +247,19 @@ Item {
onMembershipRequestPushed: function (communityId, communityName, pubKey) { onMembershipRequestPushed: function (communityId, communityName, pubKey) {
chatColumnLayout.currentNotificationChatId = null chatColumnLayout.currentNotificationChatId = null
chatColumnLayout.currentNotificationCommunityId = communityId chatColumnLayout.currentNotificationCommunityId = communityId
//% "New membership request" //% "New membership request"
root.store.chatsModelInst.showOSNotification(qsTrId("new-membership-request"), const title = qsTrId("new-membership-request")
//% "%1 asks to join %2" //% "%1 asks to join %2"
qsTrId("-1-asks-to-join---2-").arg(Utils.getDisplayName(pubKey)).arg(communityName), const message = qsTrId("-1-asks-to-join---2-").arg(Utils.getDisplayName(pubKey)).arg(communityName)
if (Qt.platform.os === "linux") {
// Linux Notifications are not implemented in Nim/C++ yet
return systemTray.showMessage(title, message, systemTray.icon.source, 4000)
}
root.store.chatsModelInst.showOSNotification(title,
message,
Constants.osNotificationType.joinCommunityRequest, Constants.osNotificationType.joinCommunityRequest,
communityId, communityId,
"", "",

View File

@ -539,14 +539,23 @@ Item {
// Whole this Connection object should be moved to the nim side. // Whole this Connection object should be moved to the nim side.
// Left here only cause we don't have a way to deal with translations on the nim side. // Left here only cause we don't have a way to deal with translations on the nim side.
const title = isContact ? qsTrId("contact-request-accepted") :
//% "New contact request"
qsTrId("new-contact-request")
const message = //% "You can now chat with %1"
isContact ? qsTrId("you-can-now-chat-with--1").arg(Utils.removeStatusEns(name)) :
//% "%1 requests to become contacts"
qsTrId("-1-requests-to-become-contacts").arg(Utils.removeStatusEns(name))
if (Qt.platform.os === "linux") {
// Linux Notifications are not implemented in Nim/C++ yet
return systemTray.showMessage(title, message, systemTray.icon.source, 4000)
}
//% "Contact request accepted" //% "Contact request accepted"
profileModel.showOSNotification(isContact ? qsTrId("contact-request-accepted") : profileModel.showOSNotification(title,
//% "New contact request" message,
qsTrId("new-contact-request"),
//% "You can now chat with %1"
isContact ? qsTrId("you-can-now-chat-with--1").arg(Utils.removeStatusEns(name)) :
//% "%1 requests to become contacts"
qsTrId("-1-requests-to-become-contacts").arg(Utils.removeStatusEns(name)),
isContact? Constants.osNotificationType.acceptedContactRequest : isContact? Constants.osNotificationType.acceptedContactRequest :
Constants.osNotificationType.newContactRequest, Constants.osNotificationType.newContactRequest,
localAccountSensitiveSettings.useOSNotifications) localAccountSensitiveSettings.useOSNotifications)