fix(community): community would appear even if not activated
Fixes #5454
This commit is contained in:
parent
ddbe4e236d
commit
7c0dbb554a
|
@ -106,6 +106,7 @@ proc init*(self: Controller) =
|
|||
self.messageService,
|
||||
self.gifService,
|
||||
self.mailserversService,
|
||||
setActive = args.fromUserAction
|
||||
)
|
||||
|
||||
self.events.on(TOGGLE_SECTION) do(e:Args):
|
||||
|
@ -124,6 +125,7 @@ proc init*(self: Controller) =
|
|||
self.messageService,
|
||||
self.gifService,
|
||||
self.mailserversService,
|
||||
setActive = true
|
||||
)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_IMPORTED) do(e:Args):
|
||||
|
@ -140,6 +142,7 @@ proc init*(self: Controller) =
|
|||
self.messageService,
|
||||
self.gifService,
|
||||
self.mailserversService,
|
||||
setActive = false
|
||||
)
|
||||
|
||||
self.events.on(SIGNAL_COMMUNITY_LEFT) do(e:Args):
|
||||
|
@ -230,12 +233,12 @@ proc getActiveSectionId*(self: Controller): string =
|
|||
result = self.activeSectionId
|
||||
|
||||
proc setActiveSection*(self: Controller, sectionId: string, sectionType: SectionType) =
|
||||
self.activeSectionId = sectionId
|
||||
if sectionType == SectionType.Community and
|
||||
not singletonInstance.localAccountSensitiveSettings.getCommunitiesEnabled():
|
||||
# Communities are not supposed to be shown
|
||||
return
|
||||
|
||||
if(sectionType == SectionType.Chat or sectionType == SectionType.Community):
|
||||
# We need to take other actions here, in case of Chat or Community sections like
|
||||
# notify status go that unviewed mentions count is updated and so...
|
||||
echo "deal with appropriate service..."
|
||||
self.activeSectionId = sectionId
|
||||
|
||||
singletonInstance.localAccountSensitiveSettings.setActiveSection(self.activeSectionId)
|
||||
|
||||
|
|
|
@ -103,7 +103,8 @@ method communityJoined*(self: AccessInterface, community: CommunityDto, events:
|
|||
communityService: community_service.Service,
|
||||
messageService: message_service.Service,
|
||||
gifService: gif_service.Service,
|
||||
mailserversService: mailservers_service.Service) {.base.} =
|
||||
mailserversService: mailservers_service.Service,
|
||||
setActive: bool = false,) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method communityEdited*(self: AccessInterface, community: CommunityDto) {.base.} =
|
||||
|
|
|
@ -560,6 +560,7 @@ method communityJoined*[T](
|
|||
messageService: message_service.Service,
|
||||
gifService: gif_service.Service,
|
||||
mailserversService: mailservers_service.Service,
|
||||
setActive: bool = false,
|
||||
) =
|
||||
var firstCommunityJoined = false
|
||||
if (self.channelGroupModules.len == 1): # First one is personal chat section
|
||||
|
@ -588,6 +589,8 @@ method communityJoined*[T](
|
|||
self.view.model().getItemIndex(singletonInstance.userProfile.getPubKey()) + 1)
|
||||
else:
|
||||
self.view.model().addItem(communitySectionItem)
|
||||
|
||||
if setActive:
|
||||
self.setActiveSection(communitySectionItem)
|
||||
|
||||
method communityLeft*[T](self: Module[T], communityId: string) =
|
||||
|
|
|
@ -24,6 +24,7 @@ type
|
|||
CommunityArgs* = ref object of Args
|
||||
community*: CommunityDto
|
||||
error*: string
|
||||
fromUserAction*: bool
|
||||
|
||||
CommunitiesArgs* = ref object of Args
|
||||
communities*: seq[CommunityDto]
|
||||
|
@ -199,7 +200,7 @@ QtObject:
|
|||
if(not self.joinedCommunities.hasKey(community.id)):
|
||||
if (community.joined and community.isMember):
|
||||
self.joinedCommunities[community.id] = community
|
||||
self.events.emit(SIGNAL_COMMUNITY_JOINED, CommunityArgs(community: community))
|
||||
self.events.emit(SIGNAL_COMMUNITY_JOINED, CommunityArgs(community: community, fromUserAction: false))
|
||||
return
|
||||
|
||||
let prev_community = self.joinedCommunities[community.id]
|
||||
|
@ -459,7 +460,7 @@ QtObject:
|
|||
self.chatService.updateOrAddChat(chatDto)
|
||||
|
||||
self.events.emit(SIGNAL_COMMUNITIES_UPDATE, CommunitiesArgs(communities: @[updatedCommunity]))
|
||||
self.events.emit(SIGNAL_COMMUNITY_JOINED, CommunityArgs(community: updatedCommunity))
|
||||
self.events.emit(SIGNAL_COMMUNITY_JOINED, CommunityArgs(community: updatedCommunity, fromUserAction: true))
|
||||
except Exception as e:
|
||||
error "Error joining the community", msg = e.msg
|
||||
result = fmt"Error joining the community: {e.msg}"
|
||||
|
|
Loading…
Reference in New Issue