Revert "refactor(members): unify members models into one (#16508)"

This reverts commit f7823cd0b7.
This commit is contained in:
Jonathan Rainville 2024-10-28 10:46:47 -04:00 committed by GitHub
parent c47f42eb39
commit 9b1fa46b17
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 255 additions and 353 deletions

View File

@ -206,10 +206,10 @@ method onChatMemberUpdated*(self: Module, publicKey: string, memberRole: MemberR
icon = contactDetails.icon, icon = contactDetails.icon,
isContact = contactDetails.dto.isContact, isContact = contactDetails.dto.isContact,
isVerified = not isMe and contactDetails.dto.isContactVerified(), isVerified = not isMe and contactDetails.dto.isContactVerified(),
memberRole, memberRole = memberRole,
joined, joined = joined,
isUntrustworthy = contactDetails.dto.trustStatus == TrustStatus.Untrustworthy, isUntrustworthy = contactDetails.dto.trustStatus == TrustStatus.Untrustworthy,
) )
method addGroupMembers*(self: Module, pubKeys: seq[string]) = method addGroupMembers*(self: Module, pubKeys: seq[string]) =
self.controller.addGroupMembers(pubKeys) self.controller.addGroupMembers(pubKeys)

View File

@ -198,61 +198,54 @@ proc createMemberItem(self: Module, memberId, requestId: string, status: Members
membershipRequestState = status, membershipRequestState = status,
) )
method getCommunityItem(self: Module, community: CommunityDto): SectionItem = method getCommunityItem(self: Module, c: CommunityDto): SectionItem =
var memberItems: seq[MemberItem] = @[] # TODO: unite bannedMembers, pendingMemberRequests and declinedMemberRequests
for member in community.members: var members: seq[MemberItem] = @[]
var communityMemberState = MembershipRequestState.Accepted for member in c.members:
if community.pendingAndBannedMembers.hasKey(member.id): if c.pendingAndBannedMembers.hasKey(member.id):
let memberState = community.pendingAndBannedMembers[member.id].toMembershipRequestState() let communityMemberState = c.pendingAndBannedMembers[member.id]
if memberState == MembershipRequestState.BannedPending or memberState == MembershipRequestState.KickedPending: members.add(self.createMemberItem(member.id, "", toMembershipRequestState(communityMemberState)))
communityMemberState = memberState
memberItems.add(self.createMemberItem(member.id, "", communityMemberState))
var bannedMembers: seq[MemberItem] = @[] var bannedMembers: seq[MemberItem] = @[]
for memberId, communityMemberState in community.pendingAndBannedMembers: for memberId, communityMemberState in c.pendingAndBannedMembers:
bannedMembers.add(self.createMemberItem(memberId, "", toMembershipRequestState(communityMemberState))) bannedMembers.add(self.createMemberItem(memberId, "", toMembershipRequestState(communityMemberState)))
let pendingMembers = community.pendingRequestsToJoin.map(proc(requestDto: CommunityMembershipRequestDto): MemberItem =
result = self.createMemberItem(requestDto.publicKey, requestDto.id, MembershipRequestState(requestDto.state))
)
let declinedMemberItems = community.declinedRequestsToJoin.map(proc(requestDto: CommunityMembershipRequestDto): MemberItem =
result = self.createMemberItem(requestDto.publicKey, requestDto.id, MembershipRequestState(requestDto.state))
)
memberItems = concat(memberItems, pendingMembers, declinedMemberItems, bannedMembers)
return initItem( return initItem(
community.id, c.id,
SectionType.Community, SectionType.Community,
community.name, c.name,
community.memberRole, c.memberRole,
community.isControlNode, c.isControlNode,
community.description, c.description,
community.introMessage, c.introMessage,
community.outroMessage, c.outroMessage,
community.images.thumbnail, c.images.thumbnail,
community.images.banner, c.images.banner,
icon = "", icon = "",
community.color, c.color,
community.tags, c.tags,
hasNotification = false, hasNotification = false,
notificationsCount = 0, notificationsCount = 0,
active = false, active = false,
enabled = true, enabled = true,
community.joined, c.joined,
community.canJoin, c.canJoin,
community.spectated, c.spectated,
community.canManageUsers, c.canManageUsers,
community.canRequestAccess, c.canRequestAccess,
community.isMember, c.isMember,
community.permissions.access, c.permissions.access,
community.permissions.ensOnly, c.permissions.ensOnly,
community.muted, c.muted,
members = memberItems, members = members,
historyArchiveSupportEnabled = community.settings.historyArchiveSupportEnabled, historyArchiveSupportEnabled = c.settings.historyArchiveSupportEnabled,
encrypted = community.encrypted, bannedMembers = bannedMembers,
communityTokens = @[], pendingMemberRequests = c.pendingRequestsToJoin.map(proc(requestDto: CommunityMembershipRequestDto): MemberItem =
activeMembersCount = int(community.activeMembersCount), result = self.createMemberItem(requestDto.publicKey, requestDto.id, MembershipRequestState(requestDto.state))),
declinedMemberRequests = c.declinedRequestsToJoin.map(proc(requestDto: CommunityMembershipRequestDto): MemberItem =
result = self.createMemberItem(requestDto.publicKey, requestDto.id, MembershipRequestState(requestDto.state))),
encrypted = c.encrypted,
communityTokens = @[]
) )
proc getCuratedCommunityItem(self: Module, community: CommunityDto): CuratedCommunityItem = proc getCuratedCommunityItem(self: Module, community: CommunityDto): CuratedCommunityItem =
@ -309,10 +302,8 @@ method setCommunityTags*(self: Module, communityTags: string) =
self.view.setCommunityTags(communityTags) self.view.setCommunityTags(communityTags)
method setAllCommunities*(self: Module, communities: seq[CommunityDto]) = method setAllCommunities*(self: Module, communities: seq[CommunityDto]) =
var items: seq[SectionItem] = @[]
for community in communities: for community in communities:
items.add(self.getCommunityItem(community)) self.view.addItem(self.getCommunityItem(community))
self.view.model.addItems(items)
method communityAdded*(self: Module, community: CommunityDto) = method communityAdded*(self: Module, community: CommunityDto) =
self.view.addItem(self.getCommunityItem(community)) self.view.addItem(self.getCommunityItem(community))

View File

@ -359,36 +359,6 @@ proc createCommunitySectionItem[T](self: Module[T], communityDetails: CommunityD
else: else:
discard discard
var memberItems = members.map(proc(member: ChatMember): MemberItem =
var state = MembershipRequestState.Accepted
if member.id in communityDetails.pendingAndBannedMembers:
let memberState = communityDetails.pendingAndBannedMembers[member.id].toMembershipRequestState()
if memberState == MembershipRequestState.BannedPending or memberState == MembershipRequestState.KickedPending:
state = memberState
elif not member.joined:
state = MembershipRequestState.AwaitingAddress
var airdropAddress = ""
if not existingCommunity.isEmpty() and not existingCommunity.communityTokens.isNil:
airdropAddress = existingCommunity.members.getAirdropAddressForMember(member.id)
result = self.createMemberItem(
member.id,
requestId = "",
state,
member.role,
airdropAddress,
)
)
let pendingMembers = communityDetails.pendingRequestsToJoin.map(proc(requestDto: CommunityMembershipRequestDto): MemberItem =
result = self.createMemberItem(requestDto.publicKey, requestDto.id, MembershipRequestState(requestDto.state), MemberRole.None)
)
let declinedMemberItems = communityDetails.declinedRequestsToJoin.map(proc(requestDto: CommunityMembershipRequestDto): MemberItem =
result = self.createMemberItem(requestDto.publicKey, requestDto.id, MembershipRequestState(requestDto.state), MemberRole.None)
)
memberItems = concat(memberItems, pendingMembers, declinedMemberItems, bannedMembers)
result = initItem( result = initItem(
communityDetails.id, communityDetails.id,
sectionType = SectionType.Community, sectionType = SectionType.Community,
@ -416,15 +386,42 @@ proc createCommunitySectionItem[T](self: Module[T], communityDetails: CommunityD
communityDetails.permissions.access, communityDetails.permissions.access,
communityDetails.permissions.ensOnly, communityDetails.permissions.ensOnly,
communityDetails.muted, communityDetails.muted,
memberItems, # members
members.map(proc(member: ChatMember): MemberItem =
var state = MembershipRequestState.Accepted
if member.id in communityDetails.pendingAndBannedMembers:
let memberState = communityDetails.pendingAndBannedMembers[member.id].toMembershipRequestState()
if memberState == MembershipRequestState.BannedPending or memberState == MembershipRequestState.KickedPending:
state = memberState
elif not member.joined:
state = MembershipRequestState.AwaitingAddress
var airdropAddress = ""
if not existingCommunity.isEmpty() and not existingCommunity.communityTokens.isNil:
airdropAddress = existingCommunity.members.getAirdropAddressForMember(member.id)
result = self.createMemberItem(
member.id,
requestId = "",
state,
member.role,
airdropAddress,
)
),
communityDetails.settings.historyArchiveSupportEnabled, communityDetails.settings.historyArchiveSupportEnabled,
communityDetails.adminSettings.pinMessageAllMembersEnabled, communityDetails.adminSettings.pinMessageAllMembersEnabled,
bannedMembers,
# pendingMemberRequests
communityDetails.pendingRequestsToJoin.map(proc(requestDto: CommunityMembershipRequestDto): MemberItem =
result = self.createMemberItem(requestDto.publicKey, requestDto.id, MembershipRequestState(requestDto.state), MemberRole.None)
),
# declinedMemberRequests
communityDetails.declinedRequestsToJoin.map(proc(requestDto: CommunityMembershipRequestDto): MemberItem =
result = self.createMemberItem(requestDto.publicKey, requestDto.id, MembershipRequestState(requestDto.state), MemberRole.None)
),
communityDetails.encrypted, communityDetails.encrypted,
communityTokensItems, communityTokensItems,
communityDetails.pubsubTopic, communityDetails.pubsubTopic,
communityDetails.pubsubTopicKey, communityDetails.pubsubTopicKey,
communityDetails.shard.index, communityDetails.shard.index,
activeMembersCount = int(communityDetails.activeMembersCount),
) )
proc connectForNotificationsOnly[T](self: Module[T]) = proc connectForNotificationsOnly[T](self: Module[T]) =
@ -1361,7 +1358,7 @@ method newCommunityMembershipRequestReceived*[T](self: Module[T], membershipRequ
singletonInstance.globalEvents.newCommunityMembershipRequestNotification("New membership request", singletonInstance.globalEvents.newCommunityMembershipRequestNotification("New membership request",
fmt "{contactName} asks to join {community.name}", community.id) fmt "{contactName} asks to join {community.name}", community.id)
self.view.model().addMember(membershipRequest.communityId, self.createMemberItem( self.view.model().addPendingMember(membershipRequest.communityId, self.createMemberItem(
membershipRequest.publicKey, membershipRequest.publicKey,
membershipRequest.id, membershipRequest.id,
MembershipRequestState(membershipRequest.state), MembershipRequestState(membershipRequest.state),
@ -1369,7 +1366,7 @@ method newCommunityMembershipRequestReceived*[T](self: Module[T], membershipRequ
)) ))
method communityMembershipRequestCanceled*[T](self: Module[T], communityId: string, requestId: string, pubKey: string) = method communityMembershipRequestCanceled*[T](self: Module[T], communityId: string, requestId: string, pubKey: string) =
self.view.model().removeMember(communityId, pubKey) self.view.model().removePendingMember(communityId, pubKey)
method meMentionedCountChanged*[T](self: Module[T], allMentions: int) = method meMentionedCountChanged*[T](self: Module[T], allMentions: int) =
singletonInstance.globalEvents.meMentionedIconBadgeNotification(allMentions) singletonInstance.globalEvents.meMentionedIconBadgeNotification(allMentions)

View File

@ -174,17 +174,13 @@ QtObject:
self.endInsertRows() self.endInsertRows()
self.countChanged() self.countChanged()
proc findIndexForMember*(self: Model, pubKey: string): int = proc findIndexForMember(self: Model, pubKey: string): int =
for i in 0 ..< self.items.len: for i in 0 ..< self.items.len:
if self.items[i].pubKey == pubKey: if(self.items[i].pubKey == pubKey):
return i return i
return -1 return -1
proc getMemberItemByIndex*(self: Model, ind: int): MemberItem =
if ind >= 0 and ind < self.items.len:
return self.items[ind]
proc getMemberItem*(self: Model, pubKey: string): MemberItem = proc getMemberItem*(self: Model, pubKey: string): MemberItem =
let ind = self.findIndexForMember(pubKey) let ind = self.findIndexForMember(pubKey)
if ind != -1: if ind != -1:
@ -287,7 +283,6 @@ QtObject:
memberRole: MemberRole, memberRole: MemberRole,
joined: bool, joined: bool,
isUntrustworthy: bool, isUntrustworthy: bool,
membershipRequestState: MembershipRequestState = MembershipRequestState.None,
callDataChanged: bool = true, callDataChanged: bool = true,
): seq[int] = ): seq[int] =
let ind = self.findIndexForMember(pubKey) let ind = self.findIndexForMember(pubKey)
@ -312,12 +307,6 @@ QtObject:
updateRole(joined, Joined) updateRole(joined, Joined)
updateRole(isUntrustworthy, IsUntrustworthy) updateRole(isUntrustworthy, IsUntrustworthy)
var updatedMembershipRequestState = membershipRequestState
if updatedMembershipRequestState == MembershipRequestState.None:
updatedMembershipRequestState = self.items[ind].membershipRequestState
updateRoleWithValue(membershipRequestState, MembershipRequestState, updatedMembershipRequestState)
if preferredDisplayNameChanged: if preferredDisplayNameChanged:
roles.add(ModelRole.PreferredDisplayName.int) roles.add(ModelRole.PreferredDisplayName.int)
@ -352,7 +341,6 @@ QtObject:
item.memberRole, item.memberRole,
item.joined, item.joined,
item.isUntrustworthy, item.isUntrustworthy,
item.membershipRequestState,
callDataChanged = false, callDataChanged = false,
) )
@ -421,7 +409,7 @@ QtObject:
isContact: bool, isContact: bool,
isVerified: bool, isVerified: bool,
isUntrustworthy: bool, isUntrustworthy: bool,
) = ) =
let ind = self.findIndexForMember(pubKey) let ind = self.findIndexForMember(pubKey)
if ind == -1: if ind == -1:
return return
@ -439,7 +427,6 @@ QtObject:
memberRole = self.items[ind].memberRole, memberRole = self.items[ind].memberRole,
joined = self.items[ind].joined, joined = self.items[ind].joined,
isUntrustworthy, isUntrustworthy,
self.items[ind].membershipRequestState,
) )
proc setOnlineStatus*(self: Model, pubKey: string, onlineStatus: OnlineStatus) = proc setOnlineStatus*(self: Model, pubKey: string, onlineStatus: OnlineStatus) =
@ -522,9 +509,3 @@ QtObject:
break break
if not found: if not found:
result.add(pubkey) result.add(pubkey)
proc isUserBanned*(self: Model, pubkey: string): bool =
let ind = self.findIndexForMember(pubkey)
if ind == -1:
return false
return self.getMemberItemByIndex(ind).membershipRequestState == MembershipRequestState.Banned

View File

@ -49,13 +49,15 @@ type
membersModel: member_model.Model membersModel: member_model.Model
historyArchiveSupportEnabled: bool historyArchiveSupportEnabled: bool
pinMessageAllMembersEnabled: bool pinMessageAllMembersEnabled: bool
bannedMembersModel: member_model.Model
pendingMemberRequestsModel*: member_model.Model
declinedMemberRequestsModel: member_model.Model
encrypted: bool encrypted: bool
communityTokensModel: community_tokens_model.TokenModel communityTokensModel: community_tokens_model.TokenModel
pubsubTopic: string pubsubTopic: string
pubsubTopicKey: string pubsubTopicKey: string
shardIndex: int shardIndex: int
isPendingOwnershipRequest: bool isPendingOwnershipRequest: bool
activeMembersCount: int
proc initItem*( proc initItem*(
id: string, id: string,
@ -87,13 +89,15 @@ proc initItem*(
members: seq[MemberItem] = @[], members: seq[MemberItem] = @[],
historyArchiveSupportEnabled = false, historyArchiveSupportEnabled = false,
pinMessageAllMembersEnabled = false, pinMessageAllMembersEnabled = false,
bannedMembers: seq[MemberItem] = @[],
pendingMemberRequests: seq[MemberItem] = @[],
declinedMemberRequests: seq[MemberItem] = @[],
encrypted: bool = false, encrypted: bool = false,
communityTokens: seq[TokenItem] = @[], communityTokens: seq[TokenItem] = @[],
pubsubTopic = "", pubsubTopic = "",
pubsubTopicKey = "", pubsubTopicKey = "",
shardIndex = -1, shardIndex = -1,
isPendingOwnershipRequest: bool = false, isPendingOwnershipRequest: bool = false
activeMembersCount: int = 0,
): SectionItem = ): SectionItem =
result.id = id result.id = id
result.sectionType = sectionType result.sectionType = sectionType
@ -125,6 +129,12 @@ proc initItem*(
result.membersModel.setItems(members) result.membersModel.setItems(members)
result.historyArchiveSupportEnabled = historyArchiveSupportEnabled result.historyArchiveSupportEnabled = historyArchiveSupportEnabled
result.pinMessageAllMembersEnabled = pinMessageAllMembersEnabled result.pinMessageAllMembersEnabled = pinMessageAllMembersEnabled
result.bannedMembersModel = newModel()
result.bannedMembersModel.setItems(bannedMembers)
result.pendingMemberRequestsModel = newModel()
result.pendingMemberRequestsModel.setItems(pendingMemberRequests)
result.declinedMemberRequestsModel = newModel()
result.declinedMemberRequestsModel.setItems(declinedMemberRequests)
result.encrypted = encrypted result.encrypted = encrypted
result.communityTokensModel = newTokenModel() result.communityTokensModel = newTokenModel()
result.communityTokensModel.setItems(communityTokens) result.communityTokensModel.setItems(communityTokens)
@ -132,7 +142,6 @@ proc initItem*(
result.pubsubTopicKey = pubsubTopicKey result.pubsubTopicKey = pubsubTopicKey
result.shardIndex = shardIndex result.shardIndex = shardIndex
result.isPendingOwnershipRequest = isPendingOwnershipRequest result.isPendingOwnershipRequest = isPendingOwnershipRequest
result.activeMembersCount = activeMembersCount
proc isEmpty*(self: SectionItem): bool = proc isEmpty*(self: SectionItem): bool =
return self.id.len == 0 return self.id.len == 0
@ -168,6 +177,9 @@ proc `$`*(self: SectionItem): string =
members:{self.membersModel}, members:{self.membersModel},
historyArchiveSupportEnabled:{self.historyArchiveSupportEnabled}, historyArchiveSupportEnabled:{self.historyArchiveSupportEnabled},
pinMessageAllMembersEnabled:{self.pinMessageAllMembersEnabled}, pinMessageAllMembersEnabled:{self.pinMessageAllMembersEnabled},
bannedMembers:{self.bannedMembersModel},
pendingMemberRequests:{self.pendingMemberRequestsModel},
declinedMemberRequests:{self.declinedMemberRequestsModel},
encrypted:{self.encrypted}, encrypted:{self.encrypted},
communityTokensModel:{self.communityTokensModel}, communityTokensModel:{self.communityTokensModel},
isPendingOwnershipRequest:{self.isPendingOwnershipRequest} isPendingOwnershipRequest:{self.isPendingOwnershipRequest}
@ -353,8 +365,17 @@ proc updateMember*(
self.membersModel.updateItem(pubkey, name, ensName, isEnsVerified, nickname, alias, image, isContact, self.membersModel.updateItem(pubkey, name, ensName, isEnsVerified, nickname, alias, image, isContact,
isVerified, isUntrustworthy) isVerified, isUntrustworthy)
proc bannedMembers*(self: SectionItem): member_model.Model {.inline.} =
self.bannedMembersModel
proc amIBanned*(self: SectionItem): bool {.inline.} = proc amIBanned*(self: SectionItem): bool {.inline.} =
return self.membersModel.isUserBanned(singletonInstance.userProfile.getPubKey()) self.bannedMembersModel.isContactWithIdAdded(singletonInstance.userProfile.getPubKey())
proc pendingMemberRequests*(self: SectionItem): member_model.Model {.inline.} =
self.pendingMemberRequestsModel
proc declinedMemberRequests*(self: SectionItem): member_model.Model {.inline.} =
self.declinedMemberRequestsModel
proc isPendingOwnershipRequest*(self: SectionItem): bool {.inline.} = proc isPendingOwnershipRequest*(self: SectionItem): bool {.inline.} =
self.isPendingOwnershipRequest self.isPendingOwnershipRequest
@ -417,10 +438,14 @@ proc communityTokens*(self: SectionItem): community_tokens_model.TokenModel {.in
self.communityTokensModel self.communityTokensModel
proc updatePendingRequestLoadingState*(self: SectionItem, memberKey: string, loading: bool) {.inline.} = proc updatePendingRequestLoadingState*(self: SectionItem, memberKey: string, loading: bool) {.inline.} =
self.membersModel.updateLoadingState(memberKey, loading) self.pendingMemberRequestsModel.updateLoadingState(memberKey, loading)
proc updateMembershipStatus*(self: SectionItem, memberKey: string, state: MembershipRequestState) {.inline.} = proc updateMembershipStatus*(self: SectionItem, memberKey: string, state: MembershipRequestState) {.inline.} =
self.membersModel.updateMembershipStatus(memberKey, state) case state:
of MembershipRequestState.Banned, MembershipRequestState.BannedWithAllMessagesDelete, MembershipRequestState.UnbannedPending:
self.bannedMembersModel.updateMembershipStatus(memberKey, state)
else:
self.membersModel.updateMembershipStatus(memberKey, state)
proc pubsubTopic*(self: SectionItem): string {.inline.} = proc pubsubTopic*(self: SectionItem): string {.inline.} =
self.pubsubTopic self.pubsubTopic
@ -439,9 +464,3 @@ proc shardIndex*(self: SectionItem): int {.inline.} =
proc `shardIndex=`*(self: var SectionItem, value: int) {.inline.} = proc `shardIndex=`*(self: var SectionItem, value: int) {.inline.} =
self.shardIndex = value self.shardIndex = value
proc activeMembersCount*(self: SectionItem): int {.inline.} =
self.activeMembersCount
proc `activeMembersCount=`*(self: var SectionItem, value: int) {.inline.} =
self.activeMembersCount = value

View File

@ -37,14 +37,16 @@ type
MembersModel MembersModel
HistoryArchiveSupportEnabled HistoryArchiveSupportEnabled
PinMessageAllMembersEnabled PinMessageAllMembersEnabled
BannedMembersModel
Encrypted Encrypted
CommunityTokensModel CommunityTokensModel
PendingMemberRequestsModel
DeclinedMemberRequestsModel
AmIBanned AmIBanned
PubsubTopic PubsubTopic
PubsubTopicKey PubsubTopicKey
ShardIndex ShardIndex
IsPendingOwnershipRequest IsPendingOwnershipRequest
ActiveMembersCount
QtObject: QtObject:
type type
@ -108,17 +110,19 @@ QtObject:
ModelRole.Access.int:"access", ModelRole.Access.int:"access",
ModelRole.EnsOnly.int:"ensOnly", ModelRole.EnsOnly.int:"ensOnly",
ModelRole.Muted.int:"muted", ModelRole.Muted.int:"muted",
ModelRole.MembersModel.int:"allMembers", ModelRole.MembersModel.int:"members",
ModelRole.HistoryArchiveSupportEnabled.int:"historyArchiveSupportEnabled", ModelRole.HistoryArchiveSupportEnabled.int:"historyArchiveSupportEnabled",
ModelRole.PinMessageAllMembersEnabled.int:"pinMessageAllMembersEnabled", ModelRole.PinMessageAllMembersEnabled.int:"pinMessageAllMembersEnabled",
ModelRole.BannedMembersModel.int:"bannedMembers",
ModelRole.Encrypted.int:"encrypted", ModelRole.Encrypted.int:"encrypted",
ModelRole.CommunityTokensModel.int:"communityTokens", ModelRole.CommunityTokensModel.int:"communityTokens",
ModelRole.PendingMemberRequestsModel.int:"pendingMemberRequests",
ModelRole.DeclinedMemberRequestsModel.int:"declinedMemberRequests",
ModelRole.AmIBanned.int:"amIBanned", ModelRole.AmIBanned.int:"amIBanned",
ModelRole.PubsubTopic.int:"pubsubTopic", ModelRole.PubsubTopic.int:"pubsubTopic",
ModelRole.PubsubTopicKey.int:"pubsubTopicKey", ModelRole.PubsubTopicKey.int:"pubsubTopicKey",
ModelRole.ShardIndex.int:"shardIndex", ModelRole.ShardIndex.int:"shardIndex",
ModelRole.IsPendingOwnershipRequest.int:"isPendingOwnershipRequest", ModelRole.IsPendingOwnershipRequest.int:"isPendingOwnershipRequest",
ModelRole.ActiveMembersCount.int:"activeMembersCount",
}.toTable }.toTable
method data(self: SectionModel, index: QModelIndex, role: int): QVariant = method data(self: SectionModel, index: QModelIndex, role: int): QVariant =
@ -190,10 +194,16 @@ QtObject:
result = newQVariant(item.historyArchiveSupportEnabled) result = newQVariant(item.historyArchiveSupportEnabled)
of ModelRole.PinMessageAllMembersEnabled: of ModelRole.PinMessageAllMembersEnabled:
result = newQVariant(item.pinMessageAllMembersEnabled) result = newQVariant(item.pinMessageAllMembersEnabled)
of ModelRole.BannedMembersModel:
result = newQVariant(item.bannedMembers)
of ModelRole.Encrypted: of ModelRole.Encrypted:
result = newQVariant(item.encrypted) result = newQVariant(item.encrypted)
of ModelRole.CommunityTokensModel: of ModelRole.CommunityTokensModel:
result = newQVariant(item.communityTokens) result = newQVariant(item.communityTokens)
of ModelRole.PendingMemberRequestsModel:
result = newQVariant(item.pendingMemberRequests)
of ModelRole.DeclinedMemberRequestsModel:
result = newQVariant(item.declinedMemberRequests)
of ModelRole.AmIBanned: of ModelRole.AmIBanned:
result = newQVariant(item.amIBanned) result = newQVariant(item.amIBanned)
of ModelRole.PubsubTopic: of ModelRole.PubsubTopic:
@ -204,8 +214,6 @@ QtObject:
result = newQVariant(item.shardIndex) result = newQVariant(item.shardIndex)
of ModelRole.IsPendingOwnershipRequest: of ModelRole.IsPendingOwnershipRequest:
result = newQVariant(item.isPendingOwnershipRequest) result = newQVariant(item.isPendingOwnershipRequest)
of ModelRole.ActiveMembersCount:
result = newQVariant(item.activeMembersCount)
proc itemExists*(self: SectionModel, id: string): bool = proc itemExists*(self: SectionModel, id: string): bool =
for it in self.items: for it in self.items:
@ -322,9 +330,11 @@ QtObject:
updateRoleWithValue(pubsubTopicKey, PubsubTopicKey, item.pubsubTopicKey) updateRoleWithValue(pubsubTopicKey, PubsubTopicKey, item.pubsubTopicKey)
updateRoleWithValue(shardIndex, ShardIndex, item.shardIndex) updateRoleWithValue(shardIndex, ShardIndex, item.shardIndex)
updateRoleWithValue(isPendingOwnershipRequest, IsPendingOwnershipRequest, item.isPendingOwnershipRequest) updateRoleWithValue(isPendingOwnershipRequest, IsPendingOwnershipRequest, item.isPendingOwnershipRequest)
updateRoleWithValue(activeMembersCount, ActiveMembersCount, item.activeMembersCount)
self.items[ind].members.updateToTheseItems(item.members.getItems()) self.items[ind].members.updateToTheseItems(item.members.getItems())
self.items[ind].bannedMembers.updateToTheseItems(item.bannedMembers.getItems())
self.items[ind].pendingMemberRequests.updateToTheseItems(item.pendingMemberRequests.getItems())
self.items[ind].declinedMemberRequests.updateToTheseItems(item.declinedMemberRequests.getItems())
if roles.len == 0: if roles.len == 0:
return return
@ -347,6 +357,7 @@ QtObject:
isUntrustworthy: bool, isUntrustworthy: bool,
) = ) =
for item in self.items: for item in self.items:
# TODO refactor to use only one model https://github.com/status-im/status-desktop/issues/16433
item.members.updateItem( item.members.updateItem(
pubKey, pubKey,
displayName, displayName,
@ -359,6 +370,42 @@ QtObject:
isVerified, isVerified,
isUntrustworthy, isUntrustworthy,
) )
item.bannedMembers.updateItem(
pubKey,
displayName,
ensName,
isEnsVerified,
localNickname,
alias,
icon,
isContact,
isVerified,
isUntrustworthy,
)
item.pendingMemberRequests.updateItem(
pubKey,
displayName,
ensName,
isEnsVerified,
localNickname,
alias,
icon,
isContact,
isVerified,
isUntrustworthy,
)
item.declinedMemberRequests.updateItem(
pubKey,
displayName,
ensName,
isEnsVerified,
localNickname,
alias,
icon,
isContact,
isVerified,
isUntrustworthy,
)
proc getNthEnabledItem*(self: SectionModel, nth: int): SectionItem = proc getNthEnabledItem*(self: SectionModel, nth: int): SectionItem =
if nth >= 0 and nth < self.items.len: if nth >= 0 and nth < self.items.len:
@ -551,16 +598,16 @@ QtObject:
self.items[index].communityTokens.setItems(communityTokensItems) self.items[index].communityTokens.setItems(communityTokensItems)
proc addMember*(self: SectionModel, communityId: string, memberItem: MemberItem) = proc addPendingMember*(self: SectionModel, communityId: string, memberItem: MemberItem) =
let i = self.getItemIndex(communityId) let i = self.getItemIndex(communityId)
if i == -1: if i == -1:
return return
self.items[i].members.addItem(memberItem) self.items[i].pendingMemberRequests.addItem(memberItem)
proc removeMember*(self: SectionModel, communityId: string, memberId: string) = proc removePendingMember*(self: SectionModel, communityId: string, memberId: string) =
let i = self.getItemIndex(communityId) let i = self.getItemIndex(communityId)
if i == -1: if i == -1:
return return
self.items[i].members.removeItemById(memberId) self.items[i].pendingMemberRequests.removeItemById(memberId)

View File

@ -61,19 +61,18 @@ type MemberRole* {.pure} = enum
type MembershipRequestState* {.pure} = enum type MembershipRequestState* {.pure} = enum
None = 0, None = 0,
Pending = 1, Pending = 1,
Declined = 2, Accepted = 2,
Accepted = 3 Declined = 3,
Canceled = 4, AcceptedPending = 4,
AcceptedPending = 5, DeclinedPending = 5,
DeclinedPending = 6, Banned = 6,
AwaitingAddress = 7, Kicked = 7,
Banned = 8, BannedPending = 8,
Kicked = 9, UnbannedPending = 9,
BannedPending = 10, KickedPending = 10,
UnbannedPending = 11, AwaitingAddress = 11,
KickedPending = 12, Unbanned = 12,
Unbanned = 13, BannedWithAllMessagesDelete = 13
BannedWithAllMessagesDelete = 14
type type
ContractTransactionStatus* {.pure.} = enum ContractTransactionStatus* {.pure.} = enum

View File

@ -57,7 +57,7 @@ Item {
sourceComponent: ProfilePopupInviteFriendsPanel { sourceComponent: ProfilePopupInviteFriendsPanel {
id: panel id: panel
communityId: "communityId" community: ({ id: "communityId" })
rootStore: AppLayoutStores.RootStore { rootStore: AppLayoutStores.RootStore {
function communityHasMember(communityId, pubKey) { function communityHasMember(communityId, pubKey) {

View File

@ -18,9 +18,7 @@ import AppLayouts.Chat.stores 1.0 as ChatStores
import AppLayouts.Profile.stores 1.0 as ProfileStores import AppLayouts.Profile.stores 1.0 as ProfileStores
import AppLayouts.Wallet.stores 1.0 as WalletStore import AppLayouts.Wallet.stores 1.0 as WalletStore
import StatusQ 0.1
import StatusQ.Core.Utils 0.1 import StatusQ.Core.Utils 0.1
import SortFilterProxyModel 0.2
StackLayout { StackLayout {
id: root id: root
@ -37,12 +35,6 @@ StackLayout {
required property SharedStores.CurrenciesStore currencyStore required property SharedStores.CurrenciesStore currencyStore
property var sectionItemModel property var sectionItemModel
MembersModelAdaptor {
id: membersModelAdaptor
allMembers: !!sectionItemModel ? sectionItemModel.allMembers : null
}
property var sendModalPopup property var sendModalPopup
readonly property bool isOwner: sectionItemModel.memberRole === Constants.memberRole.owner readonly property bool isOwner: sectionItemModel.memberRole === Constants.memberRole.owner
@ -104,22 +96,23 @@ StackLayout {
id: joinCommunityViewComponent id: joinCommunityViewComponent
JoinCommunityView { JoinCommunityView {
id: joinCommunityView id: joinCommunityView
readonly property string communityId: sectionItemModel.id readonly property var communityData: sectionItemModel
name: sectionItemModel.name readonly property string communityId: communityData.id
introMessage: sectionItemModel.introMessage name: communityData.name
communityDesc: sectionItemModel.description introMessage: communityData.introMessage
color: sectionItemModel.color communityDesc: communityData.description
image: sectionItemModel.image color: communityData.color
membersCount: membersModelAdaptor.joinedMembers.ModelCount.count image: communityData.image
membersCount: communityData.members.count
accessType: mainViewLoader.accessType accessType: mainViewLoader.accessType
joinCommunity: true joinCommunity: true
amISectionAdmin: sectionItemModel.memberRole === Constants.memberRole.owner || amISectionAdmin: communityData.memberRole === Constants.memberRole.owner ||
sectionItemModel.memberRole === Constants.memberRole.admin || communityData.memberRole === Constants.memberRole.admin ||
sectionItemModel.memberRole === Constants.memberRole.tokenMaster communityData.memberRole === Constants.memberRole.tokenMaster
communityItemsModel: root.rootStore.communityItemsModel communityItemsModel: root.rootStore.communityItemsModel
requirementsMet: root.permissionsStore.allTokenRequirementsMet requirementsMet: root.permissionsStore.allTokenRequirementsMet
requirementsCheckPending: root.rootStore.permissionsCheckOngoing requirementsCheckPending: root.rootStore.permissionsCheckOngoing
requiresRequest: !sectionItemModel.amIMember requiresRequest: !communityData.amIMember
communityHoldingsModel: root.permissionsStore.becomeMemberPermissionsModel communityHoldingsModel: root.permissionsStore.becomeMemberPermissionsModel
viewOnlyHoldingsModel: root.permissionsStore.viewOnlyPermissionsModel viewOnlyHoldingsModel: root.permissionsStore.viewOnlyPermissionsModel
viewAndPostHoldingsModel: root.permissionsStore.viewAndPostPermissionsModel viewAndPostHoldingsModel: root.permissionsStore.viewAndPostPermissionsModel
@ -132,13 +125,13 @@ StackLayout {
onNotificationButtonClicked: Global.openActivityCenterPopup() onNotificationButtonClicked: Global.openActivityCenterPopup()
onAdHocChatButtonClicked: rootStore.openCloseCreateChatView() onAdHocChatButtonClicked: rootStore.openCloseCreateChatView()
onRequestToJoinClicked: { onRequestToJoinClicked: {
Global.communityIntroPopupRequested(joinCommunityView.communityId, sectionItemModel.name, Global.communityIntroPopupRequested(joinCommunityView.communityId, communityData.name,
sectionItemModel.introMessage, sectionItemModel.image, communityData.introMessage, communityData.image,
root.isInvitationPending) root.isInvitationPending)
} }
onInvitationPendingClicked: { onInvitationPendingClicked: {
Global.communityIntroPopupRequested(joinCommunityView.communityId, sectionItemModel.name, sectionItemModel.introMessage, Global.communityIntroPopupRequested(joinCommunityView.communityId, communityData.name, communityData.introMessage,
sectionItemModel.image, root.isInvitationPending) communityData.image, root.isInvitationPending)
} }
} }
} }
@ -164,7 +157,6 @@ StackLayout {
currencyStore: root.currencyStore currencyStore: root.currencyStore
sendModalPopup: root.sendModalPopup sendModalPopup: root.sendModalPopup
sectionItemModel: root.sectionItemModel sectionItemModel: root.sectionItemModel
joinedMembersCount: membersModelAdaptor.joinedMembers.ModelCount.count
amIMember: sectionItem.amIMember amIMember: sectionItem.amIMember
amISectionAdmin: root.sectionItemModel.memberRole === Constants.memberRole.owner || amISectionAdmin: root.sectionItemModel.memberRole === Constants.memberRole.owner ||
root.sectionItemModel.memberRole === Constants.memberRole.admin || root.sectionItemModel.memberRole === Constants.memberRole.admin ||
@ -258,11 +250,7 @@ StackLayout {
isPendingOwnershipRequest: root.isPendingOwnershipRequest isPendingOwnershipRequest: root.isPendingOwnershipRequest
chatCommunitySectionModule: root.rootStore.chatCommunitySectionModule chatCommunitySectionModule: root.rootStore.chatCommunitySectionModule
community: root.sectionItemModel community: sectionItemModel
joinedMembers: membersModelAdaptor.joinedMembers
bannedMembers: membersModelAdaptor.bannedMembers
pendingMembers: membersModelAdaptor.pendingMembers
declinedMembers: membersModelAdaptor.declinedMembers
communitySettingsDisabled: root.communitySettingsDisabled communitySettingsDisabled: root.communitySettingsDisabled
onCommunitySettingsDisabledChanged: if (communitySettingsDisabled) goTo(Constants.CommunitySettingsSections.Overview) onCommunitySettingsDisabledChanged: if (communitySettingsDisabled) goTo(Constants.CommunitySettingsSections.Overview)
@ -275,11 +263,12 @@ StackLayout {
id: controlNodeOfflineComponent id: controlNodeOfflineComponent
ControlNodeOfflineCommunityView { ControlNodeOfflineCommunityView {
id: controlNodeOfflineView id: controlNodeOfflineView
name: root.sectionItemModel.name readonly property var communityData: sectionItemModel
communityDesc: root.sectionItemModel.description name: communityData.name
color: root.sectionItemModel.color communityDesc: communityData.description
image: root.sectionItemModel.image color: communityData.color
membersCount: membersModelAdaptor.joinedMembers.ModelCount.count image: communityData.image
membersCount: communityData.members.count
communityItemsModel: root.rootStore.communityItemsModel communityItemsModel: root.rootStore.communityItemsModel
notificationCount: activityCenterStore.unreadNotificationsCount notificationCount: activityCenterStore.unreadNotificationsCount
hasUnseenNotifications: activityCenterStore.hasUnseenNotifications hasUnseenNotifications: activityCenterStore.hasUnseenNotifications
@ -293,11 +282,11 @@ StackLayout {
BannedMemberCommunityView { BannedMemberCommunityView {
id: communityBanView id: communityBanView
readonly property var communityData: sectionItemModel readonly property var communityData: sectionItemModel
name: root.sectionItemModel.name name: communityData.name
communityDesc: root.sectionItemModel.description communityDesc: communityData.description
color: root.sectionItemModel.color color: communityData.color
image: root.sectionItemModel.image image: communityData.image
membersCount: membersModelAdaptor.joinedMembers.count membersCount: communityData.members.count
communityItemsModel: root.rootStore.communityItemsModel communityItemsModel: root.rootStore.communityItemsModel
notificationCount: activityCenterStore.unreadNotificationsCount notificationCount: activityCenterStore.unreadNotificationsCount
hasUnseenNotifications: activityCenterStore.hasUnseenNotifications hasUnseenNotifications: activityCenterStore.hasUnseenNotifications

View File

@ -50,7 +50,6 @@ StatusSectionLayout {
required property SharedStores.CurrenciesStore currencyStore required property SharedStores.CurrenciesStore currencyStore
required property var sendModalPopup required property var sendModalPopup
property var sectionItemModel property var sectionItemModel
property int joinedMembersCount
property var emojiPopup property var emojiPopup
property var stickersPopup property var stickersPopup
@ -301,8 +300,7 @@ StatusSectionLayout {
id: communtiyColumnComponent id: communtiyColumnComponent
CommunityColumnView { CommunityColumnView {
communitySectionModule: root.rootStore.chatCommunitySectionModule communitySectionModule: root.rootStore.chatCommunitySectionModule
communityData: root.sectionItemModel communityData: sectionItemModel
joinedMembersCount: root.joinedMembersCount
store: root.rootStore store: root.rootStore
communitiesStore: root.communitiesStore communitiesStore: root.communitiesStore
walletAssetsStore: root.walletAssetsStore walletAssetsStore: root.walletAssetsStore

View File

@ -1,113 +0,0 @@
import QtQml 2.15
import StatusQ 0.1
import StatusQ.Models 0.1
import StatusQ.Core.Utils 0.1
import utils 1.0
import SortFilterProxyModel 0.2
QObject {
id: root
/**
Expected model structure:
pubKey [string] - unique identifier of a member, e.g "0x3234235"
displayName [string] - member's chosen name
preferredDisplayName [string] - calculated member name according to priorities (eg: nickname has higher priority)
ensName [string] - member's ENS name
isEnsVerified [bool] - whether the ENS name was verified on chain
localNickname [string] - local nickname set by the current user
alias [string] - generated 3 word name
icon [string] - thumbnail image of the user
colorId [string] - generated color ID for the user's profile
colorHash [string] - generated color hash for the user's profile
onlineStatus [int] - the online status of the member
isContact [bool] - whether the user is a mutual contact or not
isVerified [bool] - wheter the user has been marked as verified or not
isUntrustworthy [bool] - wheter the user has been marked as untrustworthy or not
isBlocked [bool] - whether the user has been blocked or not
contactRequest [int] - state of the contact request that was sent
incomingVerificationStatus [int] - state of the verification request that was received
outgoingVerificationStatus [int] - state of the verification request that was send
memberRole [int] - role of the member in the community
joined [bool] - whether the user has joined the community
requestToJoinId [string] - the user's request to join ID
requestToJoinLoading [bool] - whether the request is being processed after an admin made an action (loading state)
airdropAddress [string] - the member's airdrop address (only available to TMs and owners)
membershipRequestState [int] - the user's membership state (pending, joined, etc.)
**/
property var allMembers
readonly property var joinedMembers: SortFilterProxyModel {
sourceModel: root.allMembers ?? null
filters: AnyOf {
ValueFilter {
roleName: "membershipRequestState"
value: Constants.CommunityMembershipRequestState.Accepted
}
ValueFilter {
roleName: "membershipRequestState"
value: Constants.CommunityMembershipRequestState.KickedPending
}
ValueFilter {
roleName: "membershipRequestState"
value: Constants.CommunityMembershipRequestState.BannedPending
}
ValueFilter {
roleName: "membershipRequestState"
value: Constants.CommunityMembershipRequestState.AwaitingAddress
}
}
}
readonly property var bannedMembers: SortFilterProxyModel {
sourceModel: root.allMembers ?? null
filters: AnyOf {
ValueFilter {
roleName: "membershipRequestState"
value: Constants.CommunityMembershipRequestState.Banned
}
ValueFilter {
roleName: "membershipRequestState"
value: Constants.CommunityMembershipRequestState.UnbannedPending
}
ValueFilter {
roleName: "membershipRequestState"
value: Constants.CommunityMembershipRequestState.BannedWithAllMessagesDelete
}
}
}
readonly property var pendingMembers: SortFilterProxyModel {
sourceModel: root.allMembers ?? null
filters: AnyOf {
ValueFilter {
roleName: "membershipRequestState"
value: Constants.CommunityMembershipRequestState.Pending
}
ValueFilter {
roleName: "membershipRequestState"
value: Constants.CommunityMembershipRequestState.AcceptedPending
}
ValueFilter {
roleName: "membershipRequestState"
value: Constants.CommunityMembershipRequestState.RejectedPending
}
}
}
readonly property var declinedMembers: SortFilterProxyModel {
sourceModel: root.allMembers ?? null
filters: ValueFilter {
roleName: "membershipRequestState"
value: Constants.CommunityMembershipRequestState.Rejected
}
}
}

View File

@ -1,7 +1,6 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import StatusQ 0.1
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import utils 1.0 import utils 1.0
@ -15,8 +14,8 @@ SettingsPage {
property RootStore rootStore property RootStore rootStore
property var membersModel property var membersModel
property var bannedMembersModel property var bannedMembersModel
property var pendingMembersModel property var pendingMemberRequestsModel
property var declinedMembersModel property var declinedMemberRequestsModel
property string communityName property string communityName
property int memberRole property int memberRole
@ -57,7 +56,7 @@ SettingsPage {
break break
} }
if (tabButton.enabled) if(tabButton.enabled)
membersTabBar.currentIndex = tabButton.TabBar.index membersTabBar.currentIndex = tabButton.TabBar.index
} }
@ -80,7 +79,7 @@ SettingsPage {
objectName: "pendingRequestsButton" objectName: "pendingRequestsButton"
width: implicitWidth width: implicitWidth
text: qsTr("Pending Requests") text: qsTr("Pending Requests")
enabled: pendingMembersModel.ModelCount.count > 0 enabled: pendingMemberRequestsModel.count > 0
} }
StatusTabButton { StatusTabButton {
@ -88,14 +87,14 @@ SettingsPage {
objectName: "declinedRequestsButton" objectName: "declinedRequestsButton"
width: implicitWidth width: implicitWidth
text: qsTr("Rejected") text: qsTr("Rejected")
enabled: declinedMembersModel.ModelCount.count > 0 enabled: declinedMemberRequestsModel.count > 0
} }
StatusTabButton { StatusTabButton {
id: bannedBtn id: bannedBtn
objectName: "bannedButton" objectName: "bannedButton"
width: implicitWidth width: implicitWidth
enabled: bannedMembersModel.ModelCount.count > 0 enabled: bannedMembersModel.count > 0
text: qsTr("Banned") text: qsTr("Banned")
} }
} }
@ -111,10 +110,10 @@ SettingsPage {
rootStore: root.rootStore rootStore: root.rootStore
memberRole: root.memberRole memberRole: root.memberRole
placeholderText: { placeholderText: {
if (root.membersModel.ModelCount.count === 0) if (root.membersModel.count === 0)
return qsTr("No members to search") return qsTr("No members to search")
return qsTr("Search %1's %n member(s)", "", root.membersModel ? root.membersModel.ModelCount.count : 0).arg(root.communityName) return qsTr("Search %1's %n member(s)", "", root.membersModel ? root.membersModel.count : 0).arg(root.communityName)
} }
panelType: MembersTabPanel.TabType.AllMembers panelType: MembersTabPanel.TabType.AllMembers
@ -139,14 +138,14 @@ SettingsPage {
} }
MembersTabPanel { MembersTabPanel {
model: root.pendingMembersModel model: root.pendingMemberRequestsModel
rootStore: root.rootStore rootStore: root.rootStore
memberRole: root.memberRole memberRole: root.memberRole
placeholderText: { placeholderText: {
if (root.pendingMembersModel.ModelCount.count === 0) if (root.pendingMemberRequestsModel.count === 0)
return qsTr("No pending requests to search") return qsTr("No pending requests to search")
return qsTr("Search %1's %n pending request(s)", "", root.pendingMembersModel.ModelCount.count).arg(root.communityName) return qsTr("Search %1's %n pending request(s)", "", root.pendingMemberRequestsModel.count).arg(root.communityName)
} }
panelType: MembersTabPanel.TabType.PendingRequests panelType: MembersTabPanel.TabType.PendingRequests
@ -158,14 +157,14 @@ SettingsPage {
} }
MembersTabPanel { MembersTabPanel {
model: root.declinedMembersModel model: root.declinedMemberRequestsModel
rootStore: root.rootStore rootStore: root.rootStore
memberRole: root.memberRole memberRole: root.memberRole
placeholderText: { placeholderText: {
if (root.declinedMembersModel.ModelCount.count === 0) if (root.declinedMemberRequestsModel.count === 0)
return qsTr("No rejected members to search") return qsTr("No rejected members to search")
return qsTr("Search %1's %n rejected member(s)", "", root.declinedMembersModel.ModelCount.count).arg(root.communityName) return qsTr("Search %1's %n rejected member(s)", "", root.declinedMemberRequestsModel.count).arg(root.communityName)
} }
panelType: MembersTabPanel.TabType.DeclinedRequests panelType: MembersTabPanel.TabType.DeclinedRequests
@ -180,10 +179,10 @@ SettingsPage {
rootStore: root.rootStore rootStore: root.rootStore
memberRole: root.memberRole memberRole: root.memberRole
placeholderText: { placeholderText: {
if (root.bannedMembersModel.ModelCount.count === 0) if (root.bannedMembersModel.count === 0)
return qsTr("No banned members to search") return qsTr("No banned members to search")
return qsTr("Search %1's %n banned member(s)", "", root.bannedMembersModel.ModelCount.count).arg(root.communityName) return qsTr("Search %1's %n banned member(s)", "", root.bannedMembersModel.count).arg(root.communityName)
} }
panelType: MembersTabPanel.TabType.BannedMembers panelType: MembersTabPanel.TabType.BannedMembers

View File

@ -25,7 +25,7 @@ ColumnLayout {
property AppLayoutStores.RootStore rootStore property AppLayoutStores.RootStore rootStore
property ProfileStores.ContactsStore contactsStore property ProfileStores.ContactsStore contactsStore
property string communityId property var community
property var pubKeys: ([]) property var pubKeys: ([])
@ -58,7 +58,7 @@ ColumnLayout {
rootStore: root.rootStore rootStore: root.rootStore
contactsStore: root.contactsStore contactsStore: root.contactsStore
communityId: root.communityId communityId: root.community.id
hideCommunityMembers: true hideCommunityMembers: true
showCheckbox: true showCheckbox: true
@ -90,11 +90,11 @@ ColumnLayout {
StatusDescriptionListItem { StatusDescriptionListItem {
Layout.fillWidth: true Layout.fillWidth: true
title: qsTr("Share community") title: qsTr("Share community")
subTitle: Utils.getCommunityShareLink(root.communityId) subTitle: Utils.getCommunityShareLink(root.community.id)
tooltip.text: qsTr("Copied!") tooltip.text: qsTr("Copied!")
asset.name: "copy" asset.name: "copy"
iconButton.onClicked: { iconButton.onClicked: {
let link = Utils.getCommunityShareLink(root.communityId) let link = Utils.getCommunityShareLink(root.community.id)
ClipboardUtils.setText(link) ClipboardUtils.setText(link)
tooltip.visible = !tooltip.visible tooltip.visible = !tooltip.visible
} }

View File

@ -17,7 +17,7 @@ StatusDialog {
required property var community required property var community
signal importControlNode(string communityId) signal importControlNode(var community)
width: 640 width: 640
@ -76,7 +76,7 @@ StatusDialog {
text: qsTr("Make this device the control node for %1").arg(root.community.name) text: qsTr("Make this device the control node for %1").arg(root.community.name)
enabled: agreementCheckBox.checked && agreementCheckBox2.checked enabled: agreementCheckBox.checked && agreementCheckBox2.checked
onClicked: { onClicked: {
root.importControlNode(root.community.id) root.importControlNode(root.community)
root.close() root.close()
} }
} }

View File

@ -96,7 +96,7 @@ StatusStackModal {
ProfilePopupInviteFriendsPanel { ProfilePopupInviteFriendsPanel {
rootStore: root.rootStore rootStore: root.rootStore
contactsStore: root.contactsStore contactsStore: root.contactsStore
communityId: root.communityId community: root.community
onPubKeysChanged: root.pubKeys = pubKeys onPubKeysChanged: root.pubKeys = pubKeys
}, },

View File

@ -44,7 +44,6 @@ Item {
required property CurrenciesStore currencyStore required property CurrenciesStore currencyStore
property bool hasAddedContacts: false property bool hasAddedContacts: false
property var communityData property var communityData
property int joinedMembersCount
property alias createChannelPopup: createChannelPopup property alias createChannelPopup: createChannelPopup
property int requestToJoinState: Constants.RequestToJoinState.None property int requestToJoinState: Constants.RequestToJoinState.None
@ -80,7 +79,7 @@ Item {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
name: communityData.name name: communityData.name
membersCount: root.joinedMembersCount membersCount: communityData.members.count
image: communityData.image image: communityData.image
color: communityData.color color: communityData.color
amISectionAdmin: root.isSectionAdmin amISectionAdmin: root.isSectionAdmin

View File

@ -38,11 +38,7 @@ StatusSectionLayout {
property ChatStores.RootStore rootStore property ChatStores.RootStore rootStore
property var chatCommunitySectionModule property var chatCommunitySectionModule
required property TokensStore tokensStore required property TokensStore tokensStore
required property var community property var community
required property var joinedMembers
required property var bannedMembers
required property var pendingMembers
required property var declinedMembers
required property TransactionStore transactionStore required property TransactionStore transactionStore
property bool communitySettingsDisabled property bool communitySettingsDisabled
property var sendModalPopup property var sendModalPopup
@ -113,7 +109,7 @@ StatusSectionLayout {
id: communityHeader id: communityHeader
title: community.name title: community.name
subTitle: qsTr("%n member(s)", "", root.joinedMembers.ModelCount.count || 0) subTitle: qsTr("%n member(s)", "", community.members.count || 0)
asset.name: community.image asset.name: community.image
asset.color: community.color asset.color: community.color
asset.isImage: true asset.isImage: true
@ -295,10 +291,10 @@ StatusSectionLayout {
sourceComponent: MembersSettingsPanel { sourceComponent: MembersSettingsPanel {
rootStore: root.rootStore rootStore: root.rootStore
membersModel: root.joinedMembers membersModel: root.community.members
bannedMembersModel: root.bannedMembers bannedMembersModel: root.community.bannedMembers
pendingMembersModel: root.pendingMembers pendingMemberRequestsModel: root.community.pendingMemberRequests
declinedMembersModel: root.declinedMembers declinedMemberRequestsModel: root.community.declinedMemberRequests
editable: root.isAdmin || root.isOwner || root.isTokenMasterOwner editable: root.isAdmin || root.isOwner || root.isTokenMasterOwner
memberRole: community.memberRole memberRole: community.memberRole
communityName: root.community.name communityName: root.community.name
@ -396,7 +392,7 @@ StatusSectionLayout {
// Models // Models
tokensModel: root.community.communityTokens tokensModel: root.community.communityTokens
membersModel: root.joinedMembers membersModel: root.community.members
flatNetworks: communityTokensStore.filteredFlatModel flatNetworks: communityTokensStore.filteredFlatModel
accounts: root.walletAccountsModel accounts: root.walletAccountsModel
referenceAssetsBySymbolModel: root.tokensStore.assetsBySymbolModel referenceAssetsBySymbolModel: root.tokensStore.assetsBySymbolModel
@ -563,7 +559,7 @@ StatusSectionLayout {
} }
} }
membersModel: root.joinedMembers membersModel: community.members
enabledChainIds: root.enabledChainIds enabledChainIds: root.enabledChainIds
onEnableNetwork: root.enableNetwork(chainId) onEnableNetwork: root.enableNetwork(chainId)

View File

@ -57,12 +57,15 @@ QObject {
}, },
FastExpressionRole { FastExpressionRole {
name: "membersCount" name: "membersCount"
expression: model.allMembers.rowCount() expression: model.members.count
expectedRoles: ["allMembers"] expectedRoles: ["members"]
}, },
ConstantRole { FastExpressionRole {
name: "showcaseVisibility" name: "showcaseVisibility"
value: Constants.ShowcaseVisibility.Everyone expression: getShowcaseVisibility()
function getShowcaseVisibility() {
return Constants.ShowcaseVisibility.Everyone
}
}, },
FastExpressionRole { FastExpressionRole {
name: "isShowcaseLoading" name: "isShowcaseLoading"

View File

@ -55,12 +55,12 @@ QObject {
}, },
FastExpressionRole { FastExpressionRole {
name: "membersCount" name: "membersCount"
expression: model.allMembers.rowCount() expression: model.members.count
expectedRoles: ["allMembers"] expectedRoles: ["members"]
}, },
ConstantRole { FastExpressionRole {
name: "isShowcaseLoading" name: "isShowcaseLoading"
value: false expression: false
} }
] ]
filters: ValueFilter { filters: ValueFilter {

View File

@ -79,7 +79,7 @@ QtObject {
property var communitiesModuleInst: Global.appIsReady? communitiesModule : null property var communitiesModuleInst: Global.appIsReady? communitiesModule : null
readonly property var communitiesList: SortFilterProxyModel { property var communitiesList: SortFilterProxyModel {
sourceModel: root.mainModuleInst.sectionsModel sourceModel: root.mainModuleInst.sectionsModel
filters: ValueFilter { filters: ValueFilter {
roleName: "sectionType" roleName: "sectionType"

View File

@ -963,7 +963,7 @@ QtObject {
id: importControlNodePopup id: importControlNodePopup
ImportControlNodePopup { ImportControlNodePopup {
onClosed: destroy() onClosed: destroy()
onImportControlNode: root.rootStore.promoteSelfToControlNode(communityId) onImportControlNode: root.rootStore.promoteSelfToControlNode(community.id)
} }
}, },

View File

@ -63,8 +63,6 @@ Item {
asset.height: 32 asset.height: 32
name: model.name ?? "" name: model.name ?? ""
memberCountVisible: model.joined || !model.encrypted memberCountVisible: model.joined || !model.encrypted
members: model.membersCount
activeUsers: model.activeMembersCount
banner: model.bannerImageData ?? "" banner: model.bannerImageData ?? ""
descriptionFontSize: 12 descriptionFontSize: 12
descriptionFontColor: Theme.palette.baseColor1 descriptionFontColor: Theme.palette.baseColor1
@ -72,7 +70,7 @@ Item {
switch (model.memberRole) { switch (model.memberRole) {
case (Constants.memberRole.owner): case (Constants.memberRole.owner):
return qsTr("Owner"); return qsTr("Owner");
case (Constants.memberRole.admin): case (Constants.memberRole.admin) :
return qsTr("Admin"); return qsTr("Admin");
case (Constants.memberRole.tokenMaster): case (Constants.memberRole.tokenMaster):
return qsTr("Token Master"); return qsTr("Token Master");
@ -110,7 +108,7 @@ Item {
StatusBaseText { StatusBaseText {
font.pixelSize: Theme.tertiaryTextFontSize font.pixelSize: Theme.tertiaryTextFontSize
color: Theme.palette.successColor1 color: Theme.palette.successColor1
text: qsTr("You're there too") text: qsTr("Youre there too")
} }
} }
} }

View File

@ -1322,17 +1322,16 @@ QtObject {
enum CommunityMembershipRequestState { enum CommunityMembershipRequestState {
None = 0, None = 0,
Pending, Pending,
Rejected,
Accepted, Accepted,
Canceled, Rejected,
AcceptedPending, AcceptedPending,
RejectedPending, RejectedPending,
AwaitingAddress,
Banned, Banned,
Kicked, Kicked,
BannedPending, BannedPending,
UnbannedPending, UnbannedPending,
KickedPending, KickedPending,
AwaitingAddress,
Unbanned, Unbanned,
BannedWithAllMessagesDelete BannedWithAllMessagesDelete
} }