mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-02 09:46:38 +00:00
fix: chats not updating on new messages in communities
This commit is contained in:
parent
c57356235b
commit
b76cb5682c
@ -595,6 +595,7 @@ QtObject:
|
||||
proc updateChats*(self: ChatsView, chats: seq[Chat]) =
|
||||
for chat in chats:
|
||||
if (chat.communityId != ""):
|
||||
self.communities.updateCommunityChat(chat)
|
||||
return
|
||||
self.upsertChannel(chat.id)
|
||||
self.chats.updateChat(chat)
|
||||
|
@ -39,6 +39,25 @@ QtObject:
|
||||
result.joinedCommunityList = newCommunityList(status)
|
||||
result.setup
|
||||
|
||||
proc updateCommunityChat*(self: CommunitiesView, newChat: Chat) =
|
||||
var community = self.joinedCommunityList.getCommunityById(newChat.communityId)
|
||||
if (community.id == ""):
|
||||
return
|
||||
var i = 0
|
||||
var found = false
|
||||
for chat in community.chats:
|
||||
if (chat.id == newChat.id):
|
||||
community.chats[i] = newChat
|
||||
found = true
|
||||
i = i + 1
|
||||
if (not found):
|
||||
community.chats.add(newChat)
|
||||
|
||||
self.joinedCommunityList.replaceCommunity(community)
|
||||
if (self.activeCommunity.active and self.activeCommunity.communityItem.id == community.id):
|
||||
self.activeCommunity.changeChats(community.chats)
|
||||
|
||||
|
||||
proc pendingRequestsToJoinForCommunity*(self: CommunitiesView, communityId: string): seq[CommunityMembershipRequest] =
|
||||
result = self.status.chat.pendingRequestsToJoinForCommunity(communityId)
|
||||
|
||||
|
@ -123,11 +123,19 @@ QtObject:
|
||||
read = nbMembers
|
||||
notify = nbMembersChanged
|
||||
|
||||
proc chatsChanged*(self: CommunityItemView) {.signal.}
|
||||
|
||||
proc getChats*(self: CommunityItemView): QVariant {.slot.} =
|
||||
result = newQVariant(self.chats)
|
||||
|
||||
proc changeChats*(self: CommunityItemView, chats: seq[Chat]) =
|
||||
self.communityItem.chats = chats
|
||||
self.chats.setChats(chats)
|
||||
self.chatsChanged()
|
||||
|
||||
QtProperty[QVariant] chats:
|
||||
read = getChats
|
||||
notify = chatsChanged
|
||||
|
||||
proc getMembers*(self: CommunityItemView): QVariant {.slot.} =
|
||||
result = newQVariant(self.members)
|
||||
|
@ -4,12 +4,12 @@ proc formatChatUpdate(response: JsonNode): (seq[Chat], seq[Message]) =
|
||||
var chats: seq[Chat] = @[]
|
||||
var messages: seq[Message] = @[]
|
||||
let pk = status_settings.getSetting[string](Setting.PublicKey, "0x0")
|
||||
if response["result"]{"chats"} != nil:
|
||||
if response["result"]{"messages"} != nil:
|
||||
for jsonMsg in response["result"]["messages"]:
|
||||
messages.add(jsonMsg.toMessage(pk))
|
||||
if response["result"]{"chats"} != nil:
|
||||
for jsonChat in response["result"]["chats"]:
|
||||
chats.add(jsonChat.toChat)
|
||||
chats.add(jsonChat.toChat)
|
||||
result = (chats, messages)
|
||||
|
||||
proc processChatUpdate(self: ChatModel, response: JsonNode): (seq[Chat], seq[Message]) =
|
||||
|
@ -46,10 +46,9 @@ proc fromEvent*(event: JsonNode): Signal =
|
||||
if event["event"]{"chats"} != nil:
|
||||
for jsonChat in event["event"]["chats"]:
|
||||
var chat = jsonChat.toChat
|
||||
if (chat.communityId == ""):
|
||||
if chatsWithMentions.contains(chat.id):
|
||||
chat.hasMentions = true
|
||||
signal.chats.add(chat)
|
||||
if chatsWithMentions.contains(chat.id):
|
||||
chat.hasMentions = true
|
||||
signal.chats.add(chat)
|
||||
|
||||
if event["event"]{"installations"} != nil:
|
||||
for jsonInstallation in event["event"]["installations"]:
|
||||
|
@ -174,8 +174,8 @@ Rectangle {
|
||||
channelContextMenu.openMenu(chatsModel.contextChannel, index)
|
||||
return;
|
||||
}
|
||||
chatsModel.setActiveChannelByIndex(index)
|
||||
chatGroupsListView.currentIndex = index
|
||||
chatsModel.setActiveChannelByIndex(index)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user