fix: ensure sync community settings are handled
This adds the missing handling of community settings that are synced when communities are created/edited etc. Needs https://github.com/status-im/status-go/pull/2701 to function. Partially addresses #5201
This commit is contained in:
parent
d58c6eb577
commit
9a926e110c
|
@ -17,6 +17,7 @@ type MessageSignal* = ref object of Signal
|
||||||
devices*: seq[DeviceDto]
|
devices*: seq[DeviceDto]
|
||||||
emojiReactions*: seq[ReactionDto]
|
emojiReactions*: seq[ReactionDto]
|
||||||
communities*: seq[CommunityDto]
|
communities*: seq[CommunityDto]
|
||||||
|
communitiesSettings*: seq[CommunitySettingsDto]
|
||||||
membershipRequests*: seq[CommunityMembershipRequestDto]
|
membershipRequests*: seq[CommunityMembershipRequestDto]
|
||||||
activityCenterNotifications*: seq[ActivityCenterNotificationDto]
|
activityCenterNotifications*: seq[ActivityCenterNotificationDto]
|
||||||
statusUpdates*: seq[StatusUpdateDto]
|
statusUpdates*: seq[StatusUpdateDto]
|
||||||
|
@ -58,6 +59,10 @@ proc fromEvent*(T: type MessageSignal, event: JsonNode): MessageSignal =
|
||||||
for jsonCommunity in event["event"]["communities"]:
|
for jsonCommunity in event["event"]["communities"]:
|
||||||
signal.communities.add(jsonCommunity.toCommunityDto())
|
signal.communities.add(jsonCommunity.toCommunityDto())
|
||||||
|
|
||||||
|
if event["event"]{"communitiesSettings"} != nil:
|
||||||
|
for jsonCommunitySettings in event["event"]["communitiesSettings"]:
|
||||||
|
signal.communitiesSettings.add(jsonCommunitySettings.toCommunitySettingsDto())
|
||||||
|
|
||||||
if event["event"]{"requestsToJoinCommunity"} != nil:
|
if event["event"]{"requestsToJoinCommunity"} != nil:
|
||||||
for jsonCommunity in event["event"]["requestsToJoinCommunity"]:
|
for jsonCommunity in event["event"]["requestsToJoinCommunity"]:
|
||||||
signal.membershipRequests.add(jsonCommunity.toCommunityMembershipRequestDto())
|
signal.membershipRequests.add(jsonCommunity.toCommunityMembershipRequestDto())
|
||||||
|
|
|
@ -112,6 +112,7 @@ QtObject:
|
||||||
proc loadCommunitiesSettings(self: Service): seq[CommunitySettingsDto]
|
proc loadCommunitiesSettings(self: Service): seq[CommunitySettingsDto]
|
||||||
proc loadMyPendingRequestsToJoin*(self: Service)
|
proc loadMyPendingRequestsToJoin*(self: Service)
|
||||||
proc handleCommunityUpdates(self: Service, communities: seq[CommunityDto], updatedChats: seq[ChatDto])
|
proc handleCommunityUpdates(self: Service, communities: seq[CommunityDto], updatedChats: seq[ChatDto])
|
||||||
|
proc handleCommunitiesSettingsUpdates(self: Service, communitiesSettings: seq[CommunitySettingsDto])
|
||||||
proc pendingRequestsToJoinForCommunity*(self: Service, communityId: string): seq[CommunityMembershipRequestDto]
|
proc pendingRequestsToJoinForCommunity*(self: Service, communityId: string): seq[CommunityMembershipRequestDto]
|
||||||
|
|
||||||
proc delete*(self: Service) =
|
proc delete*(self: Service) =
|
||||||
|
@ -152,6 +153,9 @@ QtObject:
|
||||||
# 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)
|
||||||
|
|
||||||
|
if (receivedData.communitiesSettings.len > 0):
|
||||||
|
self.handleCommunitiesSettingsUpdates(receivedData.communitiesSettings)
|
||||||
|
|
||||||
# Handling membership requests
|
# Handling membership requests
|
||||||
if(receivedData.membershipRequests.len > 0):
|
if(receivedData.membershipRequests.len > 0):
|
||||||
for membershipRequest in receivedData.membershipRequests:
|
for membershipRequest in receivedData.membershipRequests:
|
||||||
|
@ -208,6 +212,14 @@ QtObject:
|
||||||
var chatDetails = self.chatService.getChatById(fullChatId)
|
var chatDetails = self.chatService.getChatById(fullChatId)
|
||||||
result.add(chatDetails)
|
result.add(chatDetails)
|
||||||
|
|
||||||
|
proc handleCommunitiesSettingsUpdates(self: Service, communitiesSettings: seq[CommunitySettingsDto]) =
|
||||||
|
for settings in communitiesSettings:
|
||||||
|
if self.allCommunities.hasKey(settings.id):
|
||||||
|
self.allCommunities[settings.id].settings = settings
|
||||||
|
if self.joinedCommunities.hasKey(settings.id):
|
||||||
|
self.joinedCommunities[settings.id].settings = settings
|
||||||
|
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]) =
|
||||||
var community = communities[0]
|
var community = communities[0]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue