fix(communities): prevent item creation for unjoined communities

fixes: #16641
This commit is contained in:
Patryk Osmaczko 2024-10-29 10:40:58 +01:00
parent 60a1532087
commit 1839482ff6
1 changed files with 8 additions and 4 deletions

View File

@ -311,11 +311,13 @@ method setCommunityTags*(self: Module, communityTags: string) =
method setAllCommunities*(self: Module, communities: seq[CommunityDto]) = method setAllCommunities*(self: Module, communities: seq[CommunityDto]) =
var items: seq[SectionItem] = @[] var items: seq[SectionItem] = @[]
for community in communities: for community in communities:
items.add(self.getCommunityItem(community)) if community.joined or community.spectated:
items.add(self.getCommunityItem(community))
self.view.model.addItems(items) self.view.model.addItems(items)
method communityAdded*(self: Module, community: CommunityDto) = method communityAdded*(self: Module, community: CommunityDto) =
self.view.addItem(self.getCommunityItem(community)) if community.joined or community.spectated:
self.view.addItem(self.getCommunityItem(community))
method spectateCommunity*(self: Module, communityId: string): string = method spectateCommunity*(self: Module, communityId: string): string =
self.controller.spectateCommunity(communityId) self.controller.spectateCommunity(communityId)
@ -328,7 +330,8 @@ method navigateToCommunity*(self: Module, communityId: string) =
self.delegate.setActiveSectionById(communityId) self.delegate.setActiveSectionById(communityId)
method communityEdited*(self: Module, community: CommunityDto) = method communityEdited*(self: Module, community: CommunityDto) =
self.view.updateItem(self.getCommunityItem(community)) if community.joined or community.spectated:
self.view.updateItem(self.getCommunityItem(community))
method setCuratedCommunities*(self: Module, curatedCommunities: seq[CommunityDto]) = method setCuratedCommunities*(self: Module, curatedCommunities: seq[CommunityDto]) =
for community in curatedCommunities: for community in curatedCommunities:
@ -430,7 +433,8 @@ method isMyCommunityRequestPending*(self: Module, communityId: string): bool =
self.controller.isMyCommunityRequestPending(communityId) self.controller.isMyCommunityRequestPending(communityId)
method communityDataImported*(self: Module, community: CommunityDto) = method communityDataImported*(self: Module, community: CommunityDto) =
self.view.addItem(self.getCommunityItem(community)) if community.joined or community.spectated:
self.view.addItem(self.getCommunityItem(community))
self.buildTokensAndCollectiblesFromCommunities(@[community]) self.buildTokensAndCollectiblesFromCommunities(@[community])
self.view.emitCommunityInfoRequestCompleted(community.id, "") self.view.emitCommunityInfoRequestCompleted(community.id, "")