feat(new-links-format): Adds new links to UI

Part of: #10852
This commit is contained in:
Boris Melnik 2023-07-06 14:26:30 +03:00
parent 0d354c8ce1
commit c3c74b9f61
15 changed files with 170 additions and 20 deletions

View File

@ -260,3 +260,15 @@ proc getNetwork*(self:Controller, chainId: int): NetworkDto =
proc getTokenList*(self: Controller): seq[TokenDto] =
return self.tokenService.getTokenList()
proc shareCommunityUrlWithChatKey*(self: Controller, communityId: string): string =
return self.communityService.shareCommunityUrlWithChatKey(communityId)
proc shareCommunityUrlWithData*(self: Controller, communityId: string): string =
return self.communityService.shareCommunityUrlWithData(communityId)
proc shareCommunityChannelUrlWithChatKey*(self: Controller, communityId: string, chatId: string): string =
return self.communityService.shareCommunityChannelUrlWithChatKey(communityId, chatId)
proc shareCommunityChannelUrlWithData*(self: Controller, communityId: string, chatId: string): string =
return self.communityService.shareCommunityChannelUrlWithData(communityId, chatId)

View File

@ -159,3 +159,15 @@ method onOwnedCollectiblesUpdated*(self: AccessInterface) {.base.} =
method onWalletAccountTokensRebuilt*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method shareCommunityUrlWithChatKey*(self: AccessInterface, communityId: string): string {.base.} =
raise newException(ValueError, "No implementation available")
method shareCommunityUrlWithData*(self: AccessInterface, communityId: string): string {.base.} =
raise newException(ValueError, "No implementation available")
method shareCommunityChannelUrlWithChatKey*(self: AccessInterface, communityId: string, chatId: string): string {.base.} =
raise newException(ValueError, "No implementation available")
method shareCommunityChannelUrlWithData*(self: AccessInterface, communityId: string, chatId: string): string {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -448,4 +448,16 @@ method onCommunityTokenMetadataAdded*(self: Module, communityId: string, tokenMe
if tokenMetadata.tokenType == community_dto.TokenType.ERC20 and
not self.view.tokenListModel().hasItem(tokenMetadata.symbol):
self.view.tokenListModel.addItems(@[tokenListItem])
self.view.tokenListModel.addItems(@[tokenListItem])
method shareCommunityUrlWithChatKey*(self: Module, communityId: string): string =
return self.controller.shareCommunityUrlWithChatKey(communityId)
method shareCommunityUrlWithData*(self: Module, communityId: string): string =
return self.controller.shareCommunityUrlWithData(communityId)
method shareCommunityChannelUrlWithChatKey*(self: Module, communityId: string, chatId: string): string =
return self.controller.shareCommunityChannelUrlWithChatKey(communityId, chatId)
method shareCommunityChannelUrlWithData*(self: Module, communityId: string, chatId: string): string =
return self.controller.shareCommunityChannelUrlWithData(communityId, chatId)

View File

@ -586,3 +586,15 @@ QtObject:
proc setCollectiblesListItems*(self: View, tokenListItems: seq[TokenListItem]) =
self.collectiblesListModel.setItems(tokenListItems)
proc shareCommunityUrlWithChatKey*(self: View, communityId: string): string {.slot.} =
return self.delegate.shareCommunityUrlWithChatKey(communityId)
proc shareCommunityUrlWithData*(self: View, communityId: string): string {.slot.} =
return self.delegate.shareCommunityUrlWithData(communityId)
proc shareCommunityChannelUrlWithChatKey*(self: View, communityId: string, chatId: string): string {.slot.} =
return self.delegate.shareCommunityChannelUrlWithChatKey(communityId, chatId)
proc shareCommunityChannelUrlWithData*(self: View, communityId: string, chatId: string): string {.slot.} =
return self.delegate.shareCommunityChannelUrlWithData(communityId, chatId)

View File

@ -163,4 +163,13 @@ proc getStatusForContactWithId*(self: Controller, publicKey: string): StatusUpda
return self.contactsService.getStatusForContactWithId(publicKey)
proc requestContactInfo*(self: Controller, publicKey: string) =
self.contactsService.requestContactInfo(publicKey)
self.contactsService.requestContactInfo(publicKey)
proc shareUserUrlWithData*(self: Controller, pubkey: string): string =
self.contactsService.shareUserUrlWithData(pubkey)
proc shareUserUrlWithChatKey*(self: Controller, pubkey: string): string =
self.contactsService.shareUserUrlWithChatKey(pubkey)
proc shareUserUrlWithENS*(self: Controller, pubkey: string): string =
self.contactsService.shareUserUrlWithENS(pubkey)

View File

@ -123,4 +123,13 @@ method requestContactInfo*(self: AccessInterface, publicKey: string) {.base.} =
raise newException(ValueError, "No implementation available")
method onContactInfoRequestFinished*(self: AccessInterface, publicKey: string, ok: bool) {.base.} =
raise newException(ValueError, "No implementation available")
method shareUserUrlWithData*(self: AccessInterface, pubkey: string): string {.base.} =
raise newException(ValueError, "No implementation available")
method shareUserUrlWithChatKey*(self: AccessInterface, pubkey: string): string {.base.} =
raise newException(ValueError, "No implementation available")
method shareUserUrlWithENS*(self: AccessInterface, pubkey: string): string {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -280,3 +280,12 @@ method requestContactInfo*(self: Module, publicKey: string) =
method onContactInfoRequestFinished*(self: Module, publicKey: string, ok: bool) =
self.view.onContactInfoRequestFinished(publicKey, ok)
method shareUserUrlWithData*(self: Module, pubkey: string): string =
return self.controller.shareUserUrlWithData(pubkey)
method shareUserUrlWithChatKey*(self: Module, pubkey: string): string =
return self.controller.shareUserUrlWithChatKey(pubkey)
method shareUserUrlWithENS*(self: Module, pubkey: string): string =
return self.controller.shareUserUrlWithENS(pubkey)

View File

@ -179,6 +179,15 @@ QtObject:
proc verifiedUntrustworthy*(self: View, publicKey: string) {.slot.} =
self.delegate.verifiedUntrustworthy(publicKey)
proc shareUserUrlWithData*(self: View, pubkey: string): string {.slot.} =
return self.delegate.shareUserUrlWithData(pubkey)
proc shareUserUrlWithChatKey*(self: View, pubkey: string): string {.slot.} =
return self.delegate.shareUserUrlWithChatKey(pubkey)
proc shareUserUrlWithENS*(self: View, pubkey: string): string {.slot.} =
return self.delegate.shareUserUrlWithENS(pubkey)
proc declineVerificationRequest*(self: View, publicKey: string) {.slot.} =
self.delegate.declineVerificationRequest(publicKey)

View File

@ -1865,3 +1865,30 @@ QtObject:
let community = self.getCommunityById(communityId)
return community.channelPermissions.channels.hasKey(chatId) and not community.channelPermissions.channels[chatId].viewAndPostPermissions.satisfied
proc shareCommunityUrlWithChatKey*(self: Service, communityId: string): string =
try:
let response = status_go.shareCommunityUrlWithChatKey(communityId)
return response.result.getStr
except Exception as e:
error "error while getting community url with chat key", msg = e.msg
proc shareCommunityUrlWithData*(self: Service, communityId: string): string =
try:
let response = status_go.shareCommunityUrlWithData(communityId)
return response.result.getStr
except Exception as e:
error "error while getting community url with data", msg = e.msg
proc shareCommunityChannelUrlWithChatKey*(self: Service, communityId: string, chatId: string): string =
try:
let response = status_go.shareCommunityChannelUrlWithChatKey(communityId, chatId)
return response.result.getStr
except Exception as e:
error "error while getting community channel url with chat key ", msg = e.msg
proc shareCommunityChannelUrlWithData*(self: Service, communityId: string, chatId: string): string =
try:
let response = status_go.shareCommunityChannelUrlWithData(communityId, chatId)
return response.result.getStr
except Exception as e:
error "error while getting community channel url with data ", msg = e.msg

View File

@ -816,3 +816,24 @@ QtObject:
self.threadpool.start(arg)
except Exception as e:
error "Error requesting contact info", msg = e.msg, pubkey
proc shareUserUrlWithData*(self: Service, pubkey: string): string =
try:
let response = status_contacts.shareUserUrlWithData(pubkey)
return response.result.getStr
except Exception as e:
error "Error getting user url with data", msg = e.msg, pubkey
proc shareUserUrlWithChatKey*(self: Service, pubkey: string): string =
try:
let response = status_contacts.shareUserUrlWithChatKey(pubkey)
return response.result.getStr
except Exception as e:
error "Error getting user url with chat key", msg = e.msg, pubkey
proc shareUserUrlWithENS*(self: Service, pubkey: string): string =
try:
let response = status_contacts.shareUserUrlWithENS(pubkey)
return response.result.getStr
except Exception as e:
error "Error getting user url with ens name", msg = e.msg, pubkey

View File

@ -397,6 +397,24 @@ proc shareCommunityToUsers*(communityId: string, pubKeys: seq[string], inviteMes
"inviteMessage": inviteMessage
}])
proc shareCommunityUrlWithChatKey*(communityId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return callPrivateRPC("shareCommunityURLWithChatKey".prefix, %*[communityId])
proc shareCommunityUrlWithData*(communityId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return callPrivateRPC("shareCommunityURLWithData".prefix, %*[communityId])
proc shareCommunityChannelUrlWithChatKey*(communityId: string, channelId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return callPrivateRPC("shareCommunityChannelURLWithChatKey".prefix, %*[{
"communityId": communityId,
"channelId": channelId
}])
proc shareCommunityChannelUrlWithData*(communityId: string, channelId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return callPrivateRPC("shareCommunityChannelURLWithData".prefix, %*[{
"communityId": communityId,
"channelId": channelId
}])
proc getCommunitiesSettings*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return callPrivateRPC("getCommunitiesSettings".prefix, %*[])

View File

@ -126,4 +126,13 @@ proc retractContactRequest*(pubkey: string): RpcResponse[JsonNode] {.raises: [Ex
result = callPrivateRPC("retractContactRequest".prefix, payload)
proc requestContactInfo*(pubkey: string): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("requestContactInfoFromMailserver".prefix, %*[pubkey])
result = callPrivateRPC("requestContactInfoFromMailserver".prefix, %*[pubkey])
proc shareUserUrlWithData*(pubkey: string): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("shareUserURLWithData".prefix, %*[pubkey])
proc shareUserUrlWithChatKey*(pubkey: string): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("shareUserURLWithChatKey".prefix, %*[pubkey])
proc shareUserUrlWithENS*(pubkey: string): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("shareUserURLWithENS".prefix, %*[pubkey])

View File

@ -126,4 +126,8 @@ QtObject {
function getContactPublicKeyByAddress(address) {
return "" // TODO retrive contact public key from address
}
function getLinkToProfile(publicKey) {
return root.contactsModule.shareUserUrlWithData(publicKey)
}
}

View File

@ -82,16 +82,7 @@ Pane {
incomingVerificationStatus === Constants.verificationStatus.trusted
readonly property bool isVerified: outgoingVerificationStatus === Constants.verificationStatus.verified
readonly property string linkToProfile: {
let user = ""
if (d.isCurrentUser)
user = root.profileStore.preferredName
else
user = contactDetails.name
if (!user)
user = Utils.getCompressedPk(root.publicKey)
return Constants.userLinkPrefix + user
}
readonly property string linkToProfile: root.contactsStore.getLinkToProfile(root.publicKey)
readonly property var conns: Connections {
target: root.contactsStore.myContactsModel ?? null

View File

@ -11,6 +11,7 @@ import StatusQ.Core.Utils 0.1 as StatusQUtils
QtObject {
property var mainModuleInst: typeof mainModule !== "undefined" ? mainModule : null
property var globalUtilsInst: typeof globalUtils !== "undefined" ? globalUtils : null
property var communitiesModuleInst: typeof communitiesModule !== "undefined" ? communitiesModule : null
readonly property int maxImgSizeBytes: Constants.maxUploadFilesizeMB * 1048576 /* 1 MB in bytes */
@ -485,17 +486,12 @@ QtObject {
return colorForColorId(pubKeyColorId)
}
function getCommunityShareLink(communityId, elided = false) {
function getCommunityShareLink(communityId) {
if (communityId === "") {
return ""
}
let compressedPk = communityId
if (!globalUtilsInst.isCompressedPubKey(compressedPk)) {
compressedPk = globalUtilsInst.changeCommunityKeyCompression(compressedPk)
}
return Constants.communityLinkPrefix +
(elided ? StatusQUtils.Utils.elideText(compressedPk, 4, 2) : compressedPk)
return communitiesModuleInst.shareCommunityUrlWithData(communityId)
}
function getChatKeyFromShareLink(link) {