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.events.on(SIGNAL_LOGGEDIN_USER_IMAGE_CHANGED) do(e: Args):
self.delegate.loggedInUserImageChanged() self.delegate.loggedInUserImageChanged()
let chat = self.getChat()
# Events only for the user list, so not needed in one to one chats # Events only for the user list, so not needed in one to one chats
if(self.isUsersListAvailable): if(self.isUsersListAvailable):
self.events.on(SIGNAL_CONTACT_UNTRUSTWORTHY) do(e: Args): 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(), isVerified = contactDetails.dto.isContactVerified(),
memberRole = member.role, memberRole = member.role,
joined = member.joined, 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]) = 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_permission_item
import ../../shared_models/token_criteria_item import ../../shared_models/token_criteria_item
import ../../shared_models/token_criteria_model 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 ../../shared_models/token_permission_chat_list_model
import chat_content/module as chat_content_module 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), onlineStatus = toOnlineStatus(self.controller.getStatusForContactWithId(memberId).statusType),
isContact = contactDetails.dto.isContact, isContact = contactDetails.dto.isContact,
isVerified = contactDetails.dto.isContactVerified(), isVerified = contactDetails.dto.isContactVerified(),
requestToJoinId = requestId) requestToJoinId = requestId,
)
method getCommunityItem(self: Module, c: CommunityDto): SectionItem = method getCommunityItem(self: Module, c: CommunityDto): SectionItem =
return initItem( return initItem(

View File

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

View File

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

View File

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

View File

@ -35,10 +35,16 @@ type
large*: string large*: string
banner*: string banner*: string
type RevealedAccount* = object
address*: string
chainIds*: seq[int]
isAirdropAddress*: bool
type ChatMember* = object type ChatMember* = object
id*: string id*: string
joined*: bool joined*: bool
role*: MemberRole role*: MemberRole
airdropAccount*: RevealedAccount
type CheckPermissionsResultDto* = object type CheckPermissionsResultDto* = object
criteria*: seq[bool] criteria*: seq[bool]
@ -237,6 +243,22 @@ proc toChannelMember*(jsonObj: JsonNode, memberId: string, joined: bool): ChatMe
for roleObj in rolesObj: for roleObj in rolesObj:
roles.add(roleObj.getInt) 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 result.role = MemberRole.None
if roles.contains(MemberRole.Owner.int): if roles.contains(MemberRole.Owner.int):
result.role = MemberRole.Owner result.role = MemberRole.Owner