feat(Notifications): allow users to turn of notifications for non-contacts
Partially fixes #1280
This commit is contained in:
parent
f8c5002ff8
commit
db0b765d74
|
@ -330,7 +330,7 @@ QtObject:
|
||||||
proc messagePushed*(self: ChatsView) {.signal.}
|
proc messagePushed*(self: ChatsView) {.signal.}
|
||||||
proc newMessagePushed*(self: ChatsView) {.signal.}
|
proc newMessagePushed*(self: ChatsView) {.signal.}
|
||||||
|
|
||||||
proc messageNotificationPushed*(self: ChatsView, chatId: string, text: string, messageType: string, chatType: int, timestamp: string, identicon: string, username: string, hasMention: bool) {.signal.}
|
proc messageNotificationPushed*(self: ChatsView, chatId: string, text: string, messageType: string, chatType: int, timestamp: string, identicon: string, username: string, hasMention: bool, isAddedContact: bool) {.signal.}
|
||||||
|
|
||||||
proc messagesCleared*(self: ChatsView) {.signal.}
|
proc messagesCleared*(self: ChatsView) {.signal.}
|
||||||
|
|
||||||
|
@ -347,8 +347,18 @@ QtObject:
|
||||||
if self.channelOpenTime.getOrDefault(msg.chatId, high(int64)) < msg.timestamp.parseFloat.fromUnixFloat.toUnix:
|
if self.channelOpenTime.getOrDefault(msg.chatId, high(int64)) < msg.timestamp.parseFloat.fromUnixFloat.toUnix:
|
||||||
if msg.chatId != self.activeChannel.id:
|
if msg.chatId != self.activeChannel.id:
|
||||||
let channel = self.chats.getChannelById(msg.chatId)
|
let channel = self.chats.getChannelById(msg.chatId)
|
||||||
|
let isAddedContact = channel.chatType.isOneToOne and self.status.contacts.isAdded(channel.id)
|
||||||
if not channel.muted:
|
if not channel.muted:
|
||||||
self.messageNotificationPushed(msg.chatId, escape_html(msg.text), msg.messageType, channel.chatType.int, msg.timestamp, msg.identicon, msg.alias, msg.hasMention)
|
self.messageNotificationPushed(
|
||||||
|
msg.chatId,
|
||||||
|
escape_html(msg.text),
|
||||||
|
msg.messageType,
|
||||||
|
channel.chatType.int,
|
||||||
|
msg.timestamp,
|
||||||
|
msg.identicon,
|
||||||
|
msg.alias,
|
||||||
|
msg.hasMention,
|
||||||
|
isAddedContact)
|
||||||
else:
|
else:
|
||||||
discard self.status.chat.markMessagesSeen(msg.chatId, @[msg.id])
|
discard self.status.chat.markMessagesSeen(msg.chatId, @[msg.id])
|
||||||
self.newMessagePushed()
|
self.newMessagePushed()
|
||||||
|
|
|
@ -140,9 +140,12 @@ ScrollView {
|
||||||
chatLogView.scrollToBottom(true)
|
chatLogView.scrollToBottom(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMessageNotificationPushed: function(chatId, msg, messageType, chatType, timestamp, identicon, username, hasMention) {
|
onMessageNotificationPushed: function(chatId, msg, messageType, chatType, timestamp, identicon, username, hasMention, isAddedContact) {
|
||||||
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
|
||||||
|
}
|
||||||
notificationWindow.notifyUser(chatId, msg, messageType, chatType, timestamp, identicon, username)
|
notificationWindow.notifyUser(chatId, msg, messageType, chatType, timestamp, identicon, username)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,6 +348,10 @@ ScrollView {
|
||||||
|
|
||||||
StatusSwitch {
|
StatusSwitch {
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
|
checked: appSettings.allowNotificationsFromNonContacts
|
||||||
|
onCheckedChanged: {
|
||||||
|
appSettings.allowNotificationsFromNonContacts = checked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,7 @@ ApplicationWindow {
|
||||||
property int notificationSetting: 0
|
property int notificationSetting: 0
|
||||||
property bool notificationSoundsEnabled: true
|
property bool notificationSoundsEnabled: true
|
||||||
property int notificationMessagePreviewSetting: Constants.notificationPreviewNameAndMessage
|
property int notificationMessagePreviewSetting: Constants.notificationPreviewNameAndMessage
|
||||||
|
property bool allowNotificationsFromNonContacts: false
|
||||||
property var whitelistedUnfurlingSites: ({})
|
property var whitelistedUnfurlingSites: ({})
|
||||||
property bool neverAskAboutUnfurlingAgain: false
|
property bool neverAskAboutUnfurlingAgain: false
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue