mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-22 04:21:44 +00:00
feat: intercept clicks on messages links as well
This commit is contained in:
parent
35688e9740
commit
c5241e2bf4
@ -55,6 +55,12 @@ Item {
|
||||
return;
|
||||
}
|
||||
|
||||
const data = Utils.getLinkDataForStatusLinks(link)
|
||||
if (data && data.callback) {
|
||||
return data.callback()
|
||||
}
|
||||
|
||||
|
||||
appMain.openLink(link)
|
||||
}
|
||||
|
||||
|
@ -113,31 +113,9 @@ Column {
|
||||
}
|
||||
fetched = true
|
||||
|
||||
if (link.includes(Constants.deepLinkPrefix) || link.includes(Constants.joinStatusLink)) {
|
||||
// Parse link to know what to show
|
||||
// TODO put it in another function?
|
||||
let title = "Status"
|
||||
let callback = function () {}
|
||||
|
||||
// Link to send a direct message
|
||||
let index = link.indexOf("/u/")
|
||||
if (index > -1) {
|
||||
const pk = link.substring(index + 3)
|
||||
title = qsTr("Start a 1 on 1 chat with %1").arg(utilsModel.generateAlias(pk))
|
||||
callback = function () {
|
||||
chatsModel.joinChat(pk, Constants.chatTypeOneToOne);
|
||||
}
|
||||
}
|
||||
|
||||
linkData = {
|
||||
site: qsTr("Status app link"),
|
||||
title: title,
|
||||
thumbnailUrl: "../../../../img/status.png",
|
||||
contentType: "",
|
||||
height: 0,
|
||||
width: 0,
|
||||
callback: callback
|
||||
}
|
||||
const data = Utils.getLinkDataForStatusLinks(link)
|
||||
if (data) {
|
||||
linkData = data
|
||||
return unfurledLinkComponent
|
||||
}
|
||||
|
||||
|
@ -289,6 +289,35 @@ QtObject {
|
||||
return (/( |\t|\n|\r)/.test(c))
|
||||
}
|
||||
|
||||
function getLinkDataForStatusLinks(link) {
|
||||
if (!link.includes(Constants.deepLinkPrefix) && !link.includes(Constants.joinStatusLink)) {
|
||||
return
|
||||
}
|
||||
|
||||
let title = "Status"
|
||||
let callback = function () {}
|
||||
|
||||
// Link to send a direct message
|
||||
let index = link.indexOf("/u/")
|
||||
if (index > -1) {
|
||||
const pk = link.substring(index + 3)
|
||||
title = qsTr("Start a 1 on 1 chat with %1").arg(utilsModel.generateAlias(pk))
|
||||
callback = function () {
|
||||
chatsModel.joinChat(pk, Constants.chatTypeOneToOne);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
site: qsTr("Status app link"),
|
||||
title: title,
|
||||
thumbnailUrl: "../../../../img/status.png",
|
||||
contentType: "",
|
||||
height: 0,
|
||||
width: 0,
|
||||
callback: callback
|
||||
}
|
||||
}
|
||||
|
||||
function isPunct(c) {
|
||||
return /(!|\@|#|\$|%|\^|&|\*|\(|\)|_|\+|\||-|=|\\|{|}|[|]|"|;|'|<|>|\?|,|\.|\/)/.test(c)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user