fix(Chat): ensure new active channel messages are marked as seen

Also, selecting a channel with unread messages marks them as seen as well

Closes #738
This commit is contained in:
Pascal Precht 2020-08-26 12:53:41 +02:00 committed by Iuri Matias
parent 22a86b939f
commit f47fda6d68
3 changed files with 12 additions and 0 deletions

View File

@ -177,6 +177,7 @@ QtObject:
self.activeChannel.setChatItem(selectedChannel)
self.status.chat.setActiveChannel(selectedChannel.id)
discard self.status.chat.markAllChannelMessagesRead(selectedChannel.id)
self.currentSuggestions.setNewData(self.status.contacts.getContacts())
self.activeChannelChanged()
@ -207,6 +208,7 @@ QtObject:
proc setActiveChannel*(self: ChatsView, channel: string) {.slot.} =
if(channel == ""): return
self.activeChannel.setChatItem(self.chats.getChannel(self.chats.chats.findIndexById(channel)))
discard self.status.chat.markAllChannelMessagesRead(self.activeChannel.id)
self.currentSuggestions.setNewData(self.status.contacts.getContacts())
self.activeChannelChanged()
@ -253,6 +255,7 @@ QtObject:
if not channel.muted:
self.messageNotificationPushed(msg.chatId, msg.text, msg.messageType, channel.chatType.int, msg.timestamp, msg.identicon, msg.alias)
else:
discard self.status.chat.markMessagesSeen(msg.chatId, @[msg.id])
self.newMessagePushed()
proc messageEmojiReactionId(self: ChatsView, chatId: string, messageId: string, emojiId: int): string =

View File

@ -292,6 +292,12 @@ proc markAllChannelMessagesRead*(self: ChatModel, chatId: string): JsonNode =
self.channels[chatId].unviewedMessagesCount = 0
self.events.emit("channelUpdate", ChatUpdateArgs(messages: @[], chats: @[self.channels[chatId]], contacts: @[]))
proc markMessagesSeen*(self: ChatModel, chatId: string, messageIds: seq[string]): JsonNode =
var response = status_chat.markMessagesSeen(chatId, messageIds)
result = parseJson(response)
if self.channels.hasKey(chatId):
self.channels[chatId].unviewedMessagesCount = 0
self.events.emit("channelUpdate", ChatUpdateArgs(messages: @[], chats: @[self.channels[chatId]], contacts: @[]))
proc confirmJoiningGroup*(self: ChatModel, chatId: string) =
var response = status_chat.confirmJoiningGroup(chatId)

View File

@ -154,6 +154,9 @@ proc sendStickerMessage*(chatId: string, sticker: Sticker): string =
proc markAllRead*(chatId: string): string =
callPrivateRPC("markAllRead".prefix, %* [chatId])
proc markMessagesSeen*(chatId: string, messageIds: seq[string]): string =
callPrivateRPC("markMessagesSeen".prefix, %* [chatId, messageIds])
proc confirmJoiningGroup*(chatId: string): string =
callPrivateRPC("confirmJoiningGroup".prefix, %* [chatId])