diff --git a/ui/app/AppMain.qml b/ui/app/AppMain.qml index bf081d5bac..69b928846d 100644 --- a/ui/app/AppMain.qml +++ b/ui/app/AppMain.qml @@ -169,17 +169,30 @@ RowLayout { try { const whiteListedSites = JSON.parse(whitelist) let settingsUpdated = false + + // Add Status links to whitelist + whiteListedSites.push({title: "Status", address: Constants.deepLinkPrefix, imageSite: false}) + whiteListedSites.push({title: "Status", address: Constants.joinStatusLink, imageSite: false}) + const settings = appSettings.whitelistedUnfurlingSites + + // Set Status links as true. We intercept thoseURLs so it is privacy-safe + if (!settings[Constants.deepLinkPrefix] || !settings[Constants.joinStatusLink]) { + settings[Constants.deepLinkPrefix] = true + settings[Constants.joinStatusLink] = true + settingsUpdated = true + } + const whitelistedHostnames = [] // Add whitelisted sites in to app settings that are not already there whiteListedSites.forEach(site => { - if (!settings.hasOwnProperty(site.address)) { - settings[site.address] = false - settingsUpdated = true - } - whitelistedHostnames.push(site.address) - }) + if (!settings.hasOwnProperty(site.address)) { + settings[site.address] = false + settingsUpdated = true + } + whitelistedHostnames.push(site.address) + }) // Remove any whitelisted sites from app settings that don't exist in the // whitelist from status-go Object.keys(settings).forEach(settingsHostname => { @@ -425,7 +438,7 @@ RowLayout { browserLayoutContainer.active = true; } - timelineLayoutContainer.active = this.children[currentIndex] == timelineLayoutContainer + timelineLayoutContainer.active = this.children[currentIndex] === timelineLayoutContainer if(this.children[currentIndex] === walletLayoutContainer){ walletLayoutContainer.showSigningPhrasePopup(); diff --git a/ui/imports/Utils.qml b/ui/imports/Utils.qml index e9dbd9424b..b1206ff8e3 100644 --- a/ui/imports/Utils.qml +++ b/ui/imports/Utils.qml @@ -308,32 +308,57 @@ QtObject { return (/( |\t|\n|\r)/.test(c)) } + function getLinkTitleAndCb(link) { + const result = { + title: "Status", + callback: null + } + + // Link to send a direct message + let index = link.indexOf("/u/") + if (index === -1) { + // Try /p/ as well + index = link.indexOf("/p/") + } + if (index > -1) { + const pk = link.substring(index + 3) + result.title = qsTr("Start a 1 on 1 chat with %1").arg(utilsModel.generateAlias(pk)) + result.callback = function () { + chatsModel.joinChat(pk, Constants.chatTypeOneToOne); + } + return result + } + + // Public chat + // This needs to be the last check because it is as VERY loose check + index = link.lastIndexOf("/") + if (index > -1) { + const chatId = link.substring(index + 1) + result.title = qsTr("Join the %1 public channel").arg(chatId) + result.callback = function () { + chatsModel.joinChat(chatId, Constants.chatTypePublic); + } + return result + } + + return result + } + 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); - } - } + const result = getLinkTitleAndCb(link) return { site: qsTr("Status app link"), - title: title, + title: result.title, thumbnailUrl: "../../../../img/status.png", contentType: "", height: 0, width: 0, - callback: callback + callback: result.callback } }