fix(communities): handle removed community chats properly
We were ignoring the `removedChats` in the messenger response and therefore never processed deleted community chats in the client. This commit adds `removedChats` to `handleCommunityUpdates()` and ensures that the community channel's ID is used when emitting a signal to the app. This needs: https://github.com/status-im/status-go/pull/2973 Closes #8000
This commit is contained in:
parent
c1fd4cc680
commit
d8bda2490a
|
@ -26,6 +26,7 @@ type MessageSignal* = ref object of Signal
|
||||||
activityCenterNotifications*: seq[ActivityCenterNotificationDto]
|
activityCenterNotifications*: seq[ActivityCenterNotificationDto]
|
||||||
statusUpdates*: seq[StatusUpdateDto]
|
statusUpdates*: seq[StatusUpdateDto]
|
||||||
deletedMessages*: seq[RemovedMessageDto]
|
deletedMessages*: seq[RemovedMessageDto]
|
||||||
|
removedChats*: seq[string]
|
||||||
currentStatus*: seq[StatusUpdateDto]
|
currentStatus*: seq[StatusUpdateDto]
|
||||||
settings*: seq[SettingsFieldDto]
|
settings*: seq[SettingsFieldDto]
|
||||||
clearedHistories*: seq[ClearedHistoryDto]
|
clearedHistories*: seq[ClearedHistoryDto]
|
||||||
|
@ -105,6 +106,10 @@ proc fromEvent*(T: type MessageSignal, event: JsonNode): MessageSignal =
|
||||||
for jsonRemovedMessage in event["event"]["removedMessages"]:
|
for jsonRemovedMessage in event["event"]["removedMessages"]:
|
||||||
signal.deletedMessages.add(jsonRemovedMessage.toRemovedMessageDto())
|
signal.deletedMessages.add(jsonRemovedMessage.toRemovedMessageDto())
|
||||||
|
|
||||||
|
if event["event"]{"removedChats"} != nil:
|
||||||
|
for removedChatID in event["event"]["removedChats"]:
|
||||||
|
signal.removedChats.add(removedChatID.getStr())
|
||||||
|
|
||||||
if event["event"]{"activityCenterNotifications"} != nil:
|
if event["event"]{"activityCenterNotifications"} != nil:
|
||||||
for jsonNotification in event["event"]["activityCenterNotifications"]:
|
for jsonNotification in event["event"]["activityCenterNotifications"]:
|
||||||
signal.activityCenterNotifications.add(jsonNotification.toActivityCenterNotificationDto())
|
signal.activityCenterNotifications.add(jsonNotification.toActivityCenterNotificationDto())
|
||||||
|
|
|
@ -146,7 +146,7 @@ QtObject:
|
||||||
proc loadCommunitiesSettings(self: Service): seq[CommunitySettingsDto]
|
proc loadCommunitiesSettings(self: Service): seq[CommunitySettingsDto]
|
||||||
proc loadMyPendingRequestsToJoin*(self: Service)
|
proc loadMyPendingRequestsToJoin*(self: Service)
|
||||||
proc loadMyCanceledRequestsToJoin*(self: Service)
|
proc loadMyCanceledRequestsToJoin*(self: Service)
|
||||||
proc handleCommunityUpdates(self: Service, communities: seq[CommunityDto], updatedChats: seq[ChatDto])
|
proc handleCommunityUpdates(self: Service, communities: seq[CommunityDto], updatedChats: seq[ChatDto], removedChats: seq[string])
|
||||||
proc handleCommunitiesSettingsUpdates(self: Service, communitiesSettings: seq[CommunitySettingsDto])
|
proc handleCommunitiesSettingsUpdates(self: Service, communitiesSettings: seq[CommunitySettingsDto])
|
||||||
proc pendingRequestsToJoinForCommunity*(self: Service, communityId: string): seq[CommunityMembershipRequestDto]
|
proc pendingRequestsToJoinForCommunity*(self: Service, communityId: string): seq[CommunityMembershipRequestDto]
|
||||||
proc declinedRequestsToJoinForCommunity*(self: Service, communityId: string): seq[CommunityMembershipRequestDto]
|
proc declinedRequestsToJoinForCommunity*(self: Service, communityId: string): seq[CommunityMembershipRequestDto]
|
||||||
|
@ -192,7 +192,7 @@ QtObject:
|
||||||
# Handling community updates
|
# Handling community updates
|
||||||
if (receivedData.communities.len > 0):
|
if (receivedData.communities.len > 0):
|
||||||
# Channel added removed is notified in the chats param
|
# Channel added removed is notified in the chats param
|
||||||
self.handleCommunityUpdates(receivedData.communities, receivedData.chats)
|
self.handleCommunityUpdates(receivedData.communities, receivedData.chats, receivedData.removedChats)
|
||||||
|
|
||||||
if (receivedData.communitiesSettings.len > 0):
|
if (receivedData.communitiesSettings.len > 0):
|
||||||
self.handleCommunitiesSettingsUpdates(receivedData.communitiesSettings)
|
self.handleCommunitiesSettingsUpdates(receivedData.communitiesSettings)
|
||||||
|
@ -304,7 +304,7 @@ QtObject:
|
||||||
self.joinedCommunities[settings.id].settings = settings
|
self.joinedCommunities[settings.id].settings = settings
|
||||||
self.events.emit(SIGNAL_COMMUNITY_EDITED, CommunityArgs(community: self.joinedCommunities[settings.id]))
|
self.events.emit(SIGNAL_COMMUNITY_EDITED, CommunityArgs(community: self.joinedCommunities[settings.id]))
|
||||||
|
|
||||||
proc handleCommunityUpdates(self: Service, communities: seq[CommunityDto], updatedChats: seq[ChatDto]) =
|
proc handleCommunityUpdates(self: Service, communities: seq[CommunityDto], updatedChats: seq[ChatDto], removedChats: seq[string]) =
|
||||||
var community = communities[0]
|
var community = communities[0]
|
||||||
if(not self.allCommunities.hasKey(community.id)):
|
if(not self.allCommunities.hasKey(community.id)):
|
||||||
self.allCommunities[community.id] = community
|
self.allCommunities[community.id] = community
|
||||||
|
@ -377,11 +377,11 @@ QtObject:
|
||||||
chatId: chat.id, categoryId: chat.categoryId, position: chat.position))
|
chatId: chat.id, categoryId: chat.categoryId, position: chat.position))
|
||||||
|
|
||||||
# channel was removed
|
# channel was removed
|
||||||
elif(community.chats.len < prev_community.chats.len):
|
elif((community.chats.len-removedChats.len) < prev_community.chats.len):
|
||||||
for prv_chat in prev_community.chats:
|
for prv_chat in prev_community.chats:
|
||||||
if findIndexById(prv_chat.id, community.chats) == -1:
|
if findIndexById(prv_chat.id, community.chats) == -1:
|
||||||
self.events.emit(SIGNAL_COMMUNITY_CHANNEL_DELETED, CommunityChatIdArgs(communityId: community.id,
|
self.events.emit(SIGNAL_COMMUNITY_CHANNEL_DELETED, CommunityChatIdArgs(communityId: community.id,
|
||||||
chatId: community.id&prv_chat.id))
|
chatId: prv_chat.id))
|
||||||
# some property has changed
|
# some property has changed
|
||||||
else:
|
else:
|
||||||
for chat in community.chats:
|
for chat in community.chats:
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d41fcaf8a9d95fe8d820c1928736a7a36d783032
|
Subproject commit 019d520e28f36b63959772f99a8ae79d654bdc90
|
Loading…
Reference in New Issue