feature: copy channel link menu action (#12482)
This commit is contained in:
parent
3050e97c9c
commit
b9867c2463
|
@ -59,8 +59,18 @@ StatusMenu {
|
|||
onTriggered: { root.addRemoveGroupMember() }
|
||||
}
|
||||
|
||||
StatusAction {
|
||||
text: qsTr("Copy channel link")
|
||||
icon.name: "copy"
|
||||
enabled: root.isCommunityChat
|
||||
onTriggered: {
|
||||
const link = Utils.getCommunityChannelShareLinkWithChatId(root.chatId)
|
||||
Utils.copyToClipboard(link)
|
||||
}
|
||||
}
|
||||
|
||||
StatusMenuSeparator {
|
||||
visible: root.chatType === Constants.chatType.oneToOne || root.chatType === Constants.chatType.privateGroupChat
|
||||
visible: root.chatType === Constants.chatType.oneToOne || root.chatType === Constants.chatType.privateGroupChat || root.isCommunityChat
|
||||
}
|
||||
|
||||
StatusAction {
|
||||
|
|
|
@ -15,6 +15,7 @@ QtObject {
|
|||
property var communitiesModuleInst: typeof communitiesModule !== "undefined" ? communitiesModule : null
|
||||
|
||||
readonly property int maxImgSizeBytes: Constants.maxUploadFilesizeMB * 1048576 /* 1 MB in bytes */
|
||||
readonly property int communityIdLength: 68
|
||||
|
||||
function isDigit(value) {
|
||||
return /^\d$/.test(value);
|
||||
|
@ -33,13 +34,21 @@ QtObject {
|
|||
}
|
||||
|
||||
function isCommunityPublicKey(value) {
|
||||
return (startsWith0x(value) && isHex(value) && value.length === 68) || globalUtilsInst.isCompressedPubKey(value)
|
||||
return (startsWith0x(value) && isHex(value) && value.length === communityIdLength) || globalUtilsInst.isCompressedPubKey(value)
|
||||
}
|
||||
|
||||
function isCompressedPubKey(pubKey) {
|
||||
return globalUtilsInst.isCompressedPubKey(pubKey)
|
||||
}
|
||||
|
||||
function getCommunityIdFromFullChatId(fullChatId) {
|
||||
return fullChatId.substr(0, communityIdLength)
|
||||
}
|
||||
|
||||
function getChannelUuidFromFullChatId(fullChatId) {
|
||||
return fullChatId.substr(communityIdLength, fullChatId.length)
|
||||
}
|
||||
|
||||
function isValidETHNamePrefix(value) {
|
||||
return !(value.trim() === "" || value.endsWith(".") || value.indexOf("..") > -1)
|
||||
}
|
||||
|
@ -492,6 +501,18 @@ QtObject {
|
|||
return communitiesModuleInst.shareCommunityUrlWithData(communityId)
|
||||
}
|
||||
|
||||
function getCommunityChannelShareLink(communityId, channelId) {
|
||||
if (communityId === "" || channelId === "")
|
||||
return ""
|
||||
return communitiesModuleInst.shareCommunityChannelUrlWithData(communityId, channelId)
|
||||
}
|
||||
|
||||
function getCommunityChannelShareLinkWithChatId(chatId) {
|
||||
const communityId = getCommunityIdFromFullChatId(chatId)
|
||||
const channelId = getChannelUuidFromFullChatId(chatId)
|
||||
return getCommunityChannelShareLink(communityId, channelId)
|
||||
}
|
||||
|
||||
function getChatKeyFromShareLink(link) {
|
||||
let index = link.lastIndexOf("/u/")
|
||||
if (index === -1) {
|
||||
|
|
Loading…
Reference in New Issue