diff --git a/src/app/core/signals/remote_signals/messages.nim b/src/app/core/signals/remote_signals/messages.nim index 0d0a8f865d..539d722f9a 100644 --- a/src/app/core/signals/remote_signals/messages.nim +++ b/src/app/core/signals/remote_signals/messages.nim @@ -17,6 +17,7 @@ type MessageSignal* = ref object of Signal devices*: seq[DeviceDto] emojiReactions*: seq[ReactionDto] communities*: seq[CommunityDto] + communitiesSettings*: seq[CommunitySettingsDto] membershipRequests*: seq[CommunityMembershipRequestDto] activityCenterNotifications*: seq[ActivityCenterNotificationDto] statusUpdates*: seq[StatusUpdateDto] @@ -58,6 +59,10 @@ proc fromEvent*(T: type MessageSignal, event: JsonNode): MessageSignal = for jsonCommunity in event["event"]["communities"]: 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: for jsonCommunity in event["event"]["requestsToJoinCommunity"]: signal.membershipRequests.add(jsonCommunity.toCommunityMembershipRequestDto()) diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index b0cc332cd3..cebe40786b 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -112,6 +112,7 @@ QtObject: proc loadCommunitiesSettings(self: Service): seq[CommunitySettingsDto] proc loadMyPendingRequestsToJoin*(self: Service) 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 delete*(self: Service) = @@ -152,6 +153,9 @@ QtObject: # Channel added removed is notified in the chats param self.handleCommunityUpdates(receivedData.communities, receivedData.chats) + if (receivedData.communitiesSettings.len > 0): + self.handleCommunitiesSettingsUpdates(receivedData.communitiesSettings) + # Handling membership requests if(receivedData.membershipRequests.len > 0): for membershipRequest in receivedData.membershipRequests: @@ -208,6 +212,14 @@ QtObject: var chatDetails = self.chatService.getChatById(fullChatId) 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]) = var community = communities[0]