mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-17 12:06:48 +00:00
android, desktop: don't show unwanted notifications (#5328)
* android, desktop: don't show unwanted notifications * format * fix * code style --------- Co-authored-by: Avently <7953703+avently@users.noreply.github.com>
This commit is contained in:
+11
-5
@@ -2436,9 +2436,7 @@ object ChatController {
|
||||
) {
|
||||
receiveFile(rhId, r.user, file.fileId, auto = true)
|
||||
}
|
||||
if (cItem.showNotification && (allowedToShowNotification() || chatModel.chatId.value != cInfo.id || chatModel.remoteHostId() != rhId)) {
|
||||
ntfManager.notifyMessageReceived(r.user, cInfo, cItem)
|
||||
}
|
||||
ntfManager.notifyMessageReceived(rhId, r.user, cInfo, cItem)
|
||||
}
|
||||
}
|
||||
is CR.ChatItemsStatusesUpdated ->
|
||||
@@ -2452,7 +2450,7 @@ object ChatController {
|
||||
}
|
||||
}
|
||||
is CR.ChatItemUpdated ->
|
||||
chatItemSimpleUpdate(rhId, r.user, r.chatItem)
|
||||
chatItemUpdateNotify(rhId, r.user, r.chatItem)
|
||||
is CR.ChatItemReaction -> {
|
||||
if (active(r.user)) {
|
||||
withChats {
|
||||
@@ -2950,9 +2948,17 @@ object ChatController {
|
||||
}
|
||||
|
||||
private suspend fun chatItemSimpleUpdate(rh: Long?, user: UserLike, aChatItem: AChatItem) {
|
||||
if (activeUser(rh, user)) {
|
||||
val cInfo = aChatItem.chatInfo
|
||||
val cItem = aChatItem.chatItem
|
||||
withChats { upsertChatItem(rh, cInfo, cItem) }
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun chatItemUpdateNotify(rh: Long?, user: UserLike, aChatItem: AChatItem) {
|
||||
val cInfo = aChatItem.chatInfo
|
||||
val cItem = aChatItem.chatItem
|
||||
val notify = { ntfManager.notifyMessageReceived(user, cInfo, cItem) }
|
||||
val notify = { ntfManager.notifyMessageReceived(rh, user, cInfo, cItem) }
|
||||
if (!activeUser(rh, user)) {
|
||||
notify()
|
||||
} else if (withChats { upsertChatItem(rh, cInfo, cItem) }) {
|
||||
|
||||
+11
-3
@@ -36,9 +36,17 @@ abstract class NtfManager {
|
||||
)
|
||||
)
|
||||
|
||||
fun notifyMessageReceived(user: UserLike, cInfo: ChatInfo, cItem: ChatItem) {
|
||||
if (!cInfo.ntfsEnabled) return
|
||||
displayNotification(user = user, chatId = cInfo.id, displayName = cInfo.displayName, msgText = hideSecrets(cItem))
|
||||
fun notifyMessageReceived(rhId: Long?, user: UserLike, cInfo: ChatInfo, cItem: ChatItem) {
|
||||
if (
|
||||
cItem.showNotification &&
|
||||
cInfo.ntfsEnabled &&
|
||||
(
|
||||
allowedToShowNotification() ||
|
||||
chatModel.chatId.value != cInfo.id ||
|
||||
chatModel.remoteHostId() != rhId)
|
||||
) {
|
||||
displayNotification(user = user, chatId = cInfo.id, displayName = cInfo.displayName, msgText = hideSecrets(cItem))
|
||||
}
|
||||
}
|
||||
|
||||
fun acceptContactRequestAction(userId: Long?, incognito: Boolean, chatId: ChatId) {
|
||||
|
||||
Reference in New Issue
Block a user