From 234a164597bcb26e30fe3c5b6027827e6f6e9725 Mon Sep 17 00:00:00 2001 From: Michal Iskierko Date: Fri, 28 Oct 2022 10:48:59 +0200 Subject: [PATCH] fix(@desktop/chat): Accept profile deep link in "Send Contact Request to chat key" Fix #8070 --- ui/app/AppLayouts/Chat/stores/RootStore.qml | 6 +----- .../Profile/popups/SendContactRequestModal.qml | 3 +++ ui/imports/utils/Utils.qml | 12 ++++++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ui/app/AppLayouts/Chat/stores/RootStore.qml b/ui/app/AppLayouts/Chat/stores/RootStore.qml index d9d0968c5b..664f725385 100644 --- a/ui/app/AppLayouts/Chat/stores/RootStore.qml +++ b/ui/app/AppLayouts/Chat/stores/RootStore.qml @@ -414,12 +414,8 @@ QtObject { return result } - function isStatusDeepLink(link) { - return link.includes(Constants.deepLinkPrefix) || link.includes(Constants.joinStatusLink) - } - function getLinkDataForStatusLinks(link) { - if (!isStatusDeepLink(link)) { + if (!Utils.isStatusDeepLink(link)) { return } diff --git a/ui/app/AppLayouts/Profile/popups/SendContactRequestModal.qml b/ui/app/AppLayouts/Profile/popups/SendContactRequestModal.qml index 4da8478630..feab1886ac 100644 --- a/ui/app/AppLayouts/Profile/popups/SendContactRequestModal.qml +++ b/ui/app/AppLayouts/Profile/popups/SendContactRequestModal.qml @@ -56,6 +56,9 @@ StatusModal { return } + if (Utils.isStatusDeepLink(text)) { + text = Utils.getChatKeyFromShareLink(text) + } Qt.callLater(d.lookupContact, text); } } diff --git a/ui/imports/utils/Utils.qml b/ui/imports/utils/Utils.qml index 61309a800d..61f826e571 100644 --- a/ui/imports/utils/Utils.qml +++ b/ui/imports/utils/Utils.qml @@ -451,6 +451,10 @@ QtObject { return matches[0].substring(3) } + function isStatusDeepLink(link) { + return link.includes(Constants.deepLinkPrefix) || link.includes(Constants.joinStatusLink) + } + function hasImageExtension(url) { return Constants.acceptedImageExtensions.some(ext => url.toLowerCase().includes(ext)) } @@ -604,6 +608,14 @@ QtObject { return colorForColorId(pubKeyColorId) } + function getChatKeyFromShareLink(link) { + let index = link.lastIndexOf("/u/") + if (index === -1) { + return link + } + return link.substring(index + 3) + } + function getCompressedPk(publicKey) { if (publicKey === "") { return ""