fix(communities): fix duplicated communities and joining through link
Fixes #2665
This commit is contained in:
parent
ba2b553d7c
commit
dfebe88be7
|
@ -142,6 +142,13 @@ QtObject:
|
||||||
return community.joined and community.isMember
|
return community.joined and community.isMember
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
proc userCanJoin*(self: CommunitiesView, communityId: string): bool {.slot.} =
|
||||||
|
let communities = self.getCommunitiesIfNotFetched()
|
||||||
|
for community in communities.communities:
|
||||||
|
if community.id == communityId:
|
||||||
|
return community.canJoin
|
||||||
|
return false
|
||||||
|
|
||||||
proc activeCommunityChanged*(self: CommunitiesView) {.signal.}
|
proc activeCommunityChanged*(self: CommunitiesView) {.signal.}
|
||||||
|
|
||||||
proc setActiveCommunity*(self: CommunitiesView, communityId: string) {.slot.} =
|
proc setActiveCommunity*(self: CommunitiesView, communityId: string) {.slot.} =
|
||||||
|
@ -162,6 +169,8 @@ QtObject:
|
||||||
proc joinCommunity*(self: CommunitiesView, communityId: string, setActive: bool = true): string {.slot.} =
|
proc joinCommunity*(self: CommunitiesView, communityId: string, setActive: bool = true): string {.slot.} =
|
||||||
result = ""
|
result = ""
|
||||||
try:
|
try:
|
||||||
|
if (not self.userCanJoin(communityId) or self.isUserMemberOfCommunity(communityId)):
|
||||||
|
return
|
||||||
self.status.chat.joinCommunity(communityId)
|
self.status.chat.joinCommunity(communityId)
|
||||||
self.joinedCommunityList.addCommunityItemToList(self.communityList.getCommunityById(communityId))
|
self.joinedCommunityList.addCommunityItemToList(self.communityList.getCommunityById(communityId))
|
||||||
if (setActive):
|
if (setActive):
|
||||||
|
|
|
@ -411,8 +411,12 @@ QtObject {
|
||||||
chatsModel.communities.setActiveCommunity(communityId)
|
chatsModel.communities.setActiveCommunity(communityId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const userCanJoin = chatsModel.communities.userCanJoin(communityId)
|
||||||
|
// TODO find what to do when you can't join
|
||||||
|
if (userCanJoin) {
|
||||||
chatsModel.communities.joinCommunity(communityId, true)
|
chatsModel.communities.joinCommunity(communityId, true)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue