fix(badges): fix muted chat not being marked as read
Fixes #11041 Fixes the bug where going to a muted channel with a mention doesn't mark it as read. This was because the QML doesn't call mark as read when a channel doesn't have unviewed messages. That was because our Nim code put 0 as unviewedMessageCount when a channel is muted. I changed it so that channels always have the value from status-go. No more conditions on the Nim side. Now the condition is on the QML side. So we hide the badge in QML instead. That also means that showing the number of unviewed message, even in a muted channel works. I also fixed a bug where we counted muted messages on app restart for the normal badge. Usually it didn't cause issues, because it's rare that you had messages in a muted channel and nothing else. You'd also have unread messages in an unmuted channel. so you'd go there, read it, and it would then update the parent badge. While testing this issue, I discovered that we in fact count muted channels for the parent badge. So i fixed it in this one too. So while chats don't have any Nim code for muted chats, sections do, because status-go doesn't really give us that information.
This commit is contained in:
parent
9fc8f66fbd
commit
fe8a58c5db
|
@ -554,7 +554,7 @@ method addNewChat*(
|
||||||
setChatAsActive: bool = true,
|
setChatAsActive: bool = true,
|
||||||
insertIntoModel: bool = true,
|
insertIntoModel: bool = true,
|
||||||
): Item =
|
): Item =
|
||||||
let hasNotification = not chatDto.muted and (chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0)
|
let hasNotification =chatDto.unviewedMessagesCount > 0
|
||||||
let notificationsCount = chatDto.unviewedMentionsCount
|
let notificationsCount = chatDto.unviewedMentionsCount
|
||||||
|
|
||||||
var chatName = chatDto.name
|
var chatName = chatDto.name
|
||||||
|
@ -1198,10 +1198,7 @@ proc addOrUpdateChat(self: Module,
|
||||||
|
|
||||||
if not self.chatsLoaded or chatExists:
|
if not self.chatsLoaded or chatExists:
|
||||||
# Update badges
|
# Update badges
|
||||||
var hasUnreadMessages = false
|
self.updateBadgeNotifications(chat, chat.unviewedMessagesCount > 0, chat.unviewedMentionsCount)
|
||||||
if not chat.muted:
|
|
||||||
hasUnreadMessages = chat.unviewedMessagesCount > 0
|
|
||||||
self.updateBadgeNotifications(chat, hasUnreadMessages, chat.unviewedMentionsCount)
|
|
||||||
|
|
||||||
if not self.chatsLoaded:
|
if not self.chatsLoaded:
|
||||||
return
|
return
|
||||||
|
|
|
@ -279,7 +279,8 @@ QtObject:
|
||||||
|
|
||||||
for chat in self.channelGroups[communityId].chats:
|
for chat in self.channelGroups[communityId].chats:
|
||||||
result.unviewedMentionsCount += chat.unviewedMentionsCount
|
result.unviewedMentionsCount += chat.unviewedMentionsCount
|
||||||
if chat.muted:
|
# We count the unread messages if we are unmuted and it's not a mention, we want to show a badge on mentions
|
||||||
|
if chat.unviewedMentionsCount == 0 and chat.muted:
|
||||||
continue
|
continue
|
||||||
if chat.unviewedMessagesCount > 0:
|
if chat.unviewedMessagesCount > 0:
|
||||||
result.unviewedMessagesCount = result.unviewedMessagesCount + chat.unviewedMessagesCount
|
result.unviewedMessagesCount = result.unviewedMessagesCount + chat.unviewedMessagesCount
|
||||||
|
|
|
@ -200,7 +200,7 @@ Rectangle {
|
||||||
anchors.rightMargin: 8
|
anchors.rightMargin: 8
|
||||||
StatusBadge {
|
StatusBadge {
|
||||||
id: statusBadge
|
id: statusBadge
|
||||||
readonly property bool onlyUnread: (root.notificationsCount === 0 && root.hasUnreadMessages)
|
readonly property bool onlyUnread: !root.muted && root.notificationsCount === 0 && root.hasUnreadMessages
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
color: onlyUnread ? Theme.palette.baseColor1 :
|
color: onlyUnread ? Theme.palette.baseColor1 :
|
||||||
root.muted ? Theme.palette.primaryColor2 : Theme.palette.primaryColor1
|
root.muted ? Theme.palette.primaryColor2 : Theme.palette.primaryColor1
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 60b160997c7f583c2f1e0ebbe5b995ca117e86f3
|
Subproject commit a46bf97bf3f46b07d1f447732947011e20fa499f
|
Loading…
Reference in New Issue