feat(member_model): add airdropAddress to members_model

Fixes #11540
This commit is contained in:
Jonathan Rainville 2023-07-18 15:06:53 -04:00
parent 3a24870215
commit 2807f77dff
8 changed files with 43 additions and 12 deletions

View File

@ -80,8 +80,6 @@ proc init*(self: Controller) =
self.events.on(SIGNAL_LOGGEDIN_USER_IMAGE_CHANGED) do(e: Args):
self.delegate.loggedInUserImageChanged()
let chat = self.getChat()
# Events only for the user list, so not needed in one to one chats
if(self.isUsersListAvailable):
self.events.on(SIGNAL_CONTACT_UNTRUSTWORTHY) do(e: Args):

View File

@ -132,7 +132,8 @@ proc addChatMember(self: Module, member: ChatMember) =
isVerified = contactDetails.dto.isContactVerified(),
memberRole = member.role,
joined = member.joined,
isUntrustworthy = contactDetails.dto.trustStatus == TrustStatus.Untrustworthy
isUntrustworthy = contactDetails.dto.trustStatus == TrustStatus.Untrustworthy,
airdropAddress = member.airdropAccount.address,
))
method onChatMembersAdded*(self: Module, ids: seq[string]) =

View File

@ -11,9 +11,6 @@ import ../../shared_models/token_permissions_model
import ../../shared_models/token_permission_item
import ../../shared_models/token_criteria_item
import ../../shared_models/token_criteria_model
import ../../shared_models/token_list_item
import ../../shared_models/token_list_model
import ../../shared_models/token_permission_chat_list_item
import ../../shared_models/token_permission_chat_list_model
import chat_content/module as chat_content_module

View File

@ -133,7 +133,8 @@ proc createMemberItem(self: Module, memberId, requestId: string): MemberItem =
onlineStatus = toOnlineStatus(self.controller.getStatusForContactWithId(memberId).statusType),
isContact = contactDetails.dto.isContact,
isVerified = contactDetails.dto.isContactVerified(),
requestToJoinId = requestId)
requestToJoinId = requestId,
)
method getCommunityItem(self: Module, c: CommunityDto): SectionItem =
return initItem(

View File

@ -301,7 +301,8 @@ proc createChannelGroupItem[T](self: Module[T], channelGroup: ChannelGroupDto):
onlineStatus = toOnlineStatus(self.controller.getStatusForContactWithId(member.id).statusType),
isContact = contactDetails.dto.isContact,
isVerified = contactDetails.dto.isContactVerified(),
memberRole = member.role
memberRole = member.role,
airdropAddress = member.airdropAccount.address,
)),
# pendingRequestsToJoin
if (isCommunity): communityDetails.pendingRequestsToJoin.map(x => pending_request_item.initItem(
@ -329,7 +330,7 @@ proc createChannelGroupItem[T](self: Module[T], channelGroup: ChannelGroupDto):
colorHash = contactDetails.colorHash,
onlineStatus = toOnlineStatus(self.controller.getStatusForContactWithId(bannedMemberId).statusType),
isContact = contactDetails.dto.isContact,
isVerified = contactDetails.dto.isContactVerified()
isVerified = contactDetails.dto.isContactVerified(),
)
),
# pendingMemberRequests
@ -348,7 +349,7 @@ proc createChannelGroupItem[T](self: Module[T], channelGroup: ChannelGroupDto):
onlineStatus = toOnlineStatus(self.controller.getStatusForContactWithId(requestDto.publicKey).statusType),
isContact = contactDetails.dto.isContact,
isVerified = contactDetails.dto.isContactVerified(),
requestToJoinId = requestDto.id
requestToJoinId = requestDto.id,
)
) else: @[],
# declinedMemberRequests
@ -367,7 +368,7 @@ proc createChannelGroupItem[T](self: Module[T], channelGroup: ChannelGroupDto):
onlineStatus = toOnlineStatus(self.controller.getStatusForContactWithId(requestDto.publicKey).statusType),
isContact = contactDetails.dto.isContact,
isVerified = contactDetails.dto.isContactVerified(),
requestToJoinId = requestDto.id
requestToJoinId = requestDto.id,
)
) else: @[],
channelGroup.encrypted,

View File

@ -11,6 +11,7 @@ type
joined: bool
requestToJoinId: string
requestToJoinLoading*: bool
airdropAddress*: string
# FIXME: remove defaults
proc initMemberItem*(
@ -34,13 +35,15 @@ proc initMemberItem*(
memberRole: MemberRole = MemberRole.None,
joined: bool = false,
requestToJoinId: string = "",
requestToJoinLoading: bool = false
requestToJoinLoading: bool = false,
airdropAddress: string = "",
): MemberItem =
result = MemberItem()
result.memberRole = memberRole
result.joined = joined
result.requestToJoinId = requestToJoinId
result.requestToJoinLoading = requestToJoinLoading
result.airdropAddress = airdropAddress
result.UserItem.setup(
pubKey = pubKey,
displayName = displayName,
@ -69,6 +72,7 @@ proc `$`*(self: MemberItem): string =
isEnsVerified: {self.isEnsVerified},
localNickname: {self.localNickname},
alias: {self.alias},
airdropAddress: {self.airdropAddress},
icon: {self.icon},
colorId: {self.colorId},
colorHash: {self.colorHash},
@ -105,3 +109,6 @@ proc `requestToJoinId=`*(self: MemberItem, value: string) {.inline.} =
proc requestToJoinLoading*(self: MemberItem): bool {.inline.} =
self.requestToJoinLoading
proc airdropAddress*(self: MemberItem): string {.inline.} =
self.airdropAddress

View File

@ -29,6 +29,7 @@ type
Joined
RequestToJoinId
RequestToJoinLoading
AirdropAddress
QtObject:
type
@ -96,6 +97,7 @@ QtObject:
ModelRole.Joined.int: "joined",
ModelRole.RequestToJoinId.int: "requestToJoinId",
ModelRole.RequestToJoinLoading.int: "requestToJoinLoading",
ModelRole.AirdropAddress.int: "airdropAddress",
}.toTable
method data(self: Model, index: QModelIndex, role: int): QVariant =
@ -151,6 +153,8 @@ QtObject:
result = newQVariant(item.requestToJoinId)
of ModelRole.RequestToJoinLoading:
result = newQVariant(item.requestToJoinLoading)
of ModelRole.AirdropAddress:
result = newQVariant(item.airdropAddress)
proc addItem*(self: Model, item: MemberItem) =
self.beginInsertRows(newQModelIndex(), self.items.len, self.items.len)

View File

@ -35,10 +35,16 @@ type
large*: string
banner*: string
type RevealedAccount* = object
address*: string
chainIds*: seq[int]
isAirdropAddress*: bool
type ChatMember* = object
id*: string
joined*: bool
role*: MemberRole
airdropAccount*: RevealedAccount
type CheckPermissionsResultDto* = object
criteria*: seq[bool]
@ -237,6 +243,22 @@ proc toChannelMember*(jsonObj: JsonNode, memberId: string, joined: bool): ChatMe
for roleObj in rolesObj:
roles.add(roleObj.getInt)
var revealedAccountsObj: JsonNode
if jsonObj.getProp("revealed_accounts", revealedAccountsObj):
for revealedAccountObj in revealedAccountsObj:
if revealedAccountObj["isAirdropAddress"].getBool:
var chainIdsObj: JsonNode
var chainIds: seq[int] = @[]
if revealedAccountObj.getProp("chain_ids", chainIdsObj):
for chainIdObj in chainIdsObj:
chainIds.add(chainIdObj.getInt)
result.airdropAccount = RevealedAccount(
address: revealedAccountObj["address"].getStr,
chainIds: chainIds,
isAirdropAddress: true,
)
result.role = MemberRole.None
if roles.contains(MemberRole.Owner.int):
result.role = MemberRole.Owner