feat: add setting for notifications on requests

This commit is contained in:
Jonathan Rainville 2021-05-17 16:15:34 -04:00
parent ecf8b241f0
commit a90257e141
4 changed files with 7 additions and 8 deletions

View File

@ -184,9 +184,6 @@ ScrollView {
onMessageNotificationPushed: function(chatId, msg, messageType, chatType, timestamp, identicon, username, hasMention, isAddedContact, channelName) { onMessageNotificationPushed: function(chatId, msg, messageType, chatType, timestamp, identicon, username, hasMention, isAddedContact, channelName) {
if (appSettings.notificationSetting == Constants.notifyAllMessages || if (appSettings.notificationSetting == Constants.notifyAllMessages ||
(appSettings.notificationSetting == Constants.notifyJustMentions && hasMention)) { (appSettings.notificationSetting == Constants.notifyJustMentions && hasMention)) {
if (chatType === Constants.chatTypeOneToOne && !appSettings.allowNotificationsFromNonContacts && !isAddedContact) {
return
}
if (chatId === chatsModel.activeChannel.id && applicationWindow.active === true) { if (chatId === chatsModel.activeChannel.id && applicationWindow.active === true) {
// Do not show the notif if we are in the channel already and the window is active and focused // Do not show the notif if we are in the channel already and the window is active and focused
return return

View File

@ -122,6 +122,9 @@ Rectangle {
Connections { Connections {
target: profileModel.contacts target: profileModel.contacts
onContactRequestAdded: { onContactRequestAdded: {
if (!appSettings.notifyOnNewRequests) {
return
}
systemTray.showMessage(qsTr("New contact request"), systemTray.showMessage(qsTr("New contact request"),
qsTr("%1 requests to become contacts").arg(Utils.removeStatusEns(name)), qsTr("%1 requests to become contacts").arg(Utils.removeStatusEns(name)),
SystemTrayIcon.NoIcon, SystemTrayIcon.NoIcon,

View File

@ -253,12 +253,11 @@ ScrollView {
width: parent.width width: parent.width
StatusSettingsLineButton { StatusSettingsLineButton {
//% "Receive notifications from non-contacts" text: qsTr("Notify on new requests")
text: qsTrId("receive-notifications-from-non-contacts")
isSwitch: true isSwitch: true
switchChecked: appSettings.allowNotificationsFromNonContacts switchChecked: appSettings.notifyOnNewRequests
onClicked: { onClicked: {
appSettings.allowNotificationsFromNonContacts = checked appSettings.notifyOnNewRequests = checked
} }
} }

View File

@ -123,7 +123,7 @@ RowLayout {
property bool notificationSoundsEnabled: true property bool notificationSoundsEnabled: true
property bool useOSNotifications: true property bool useOSNotifications: true
property int notificationMessagePreviewSetting: Constants.notificationPreviewNameAndMessage property int notificationMessagePreviewSetting: Constants.notificationPreviewNameAndMessage
property bool allowNotificationsFromNonContacts: false property bool notifyOnNewRequests: true
property var whitelistedUnfurlingSites: ({}) property var whitelistedUnfurlingSites: ({})
property bool neverAskAboutUnfurlingAgain: false property bool neverAskAboutUnfurlingAgain: false
property bool hideChannelSuggestions: false property bool hideChannelSuggestions: false