From 66840da455d6ca1231bfaa41b7391189ebe6ce92 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 18 Nov 2021 14:34:03 -0500 Subject: [PATCH] fix(LinkMessages): fix various problems with link messages not showing Fixes #4131 --- ui/app/AppMain.qml | 125 +++++++++--------- .../shared/views/chat/LinksMessageView.qml | 10 +- vendor/status-lib | 2 +- 3 files changed, 67 insertions(+), 70 deletions(-) diff --git a/ui/app/AppMain.qml b/ui/app/AppMain.qml index e0d443d256..9e43c0ee9e 100644 --- a/ui/app/AppMain.qml +++ b/ui/app/AppMain.qml @@ -501,71 +501,6 @@ Item { } } - - Connections { - target: profileModel - - onSettingsFileChanged: { - // Since https://github.com/status-im/status-desktop/commit/93668ff75 - // we're hiding the setting to change appearance for compact normal mode - // of the UI. For now, compact mode is the new default. - // - // Prior to this change, most likely many users are still using the - // normal mode configuration, so we have to enforce compact mode for - // those. - if (!localAccountSensitiveSettings.useCompactMode) { - localAccountSensitiveSettings.useCompactMode = true - } - - const whitelist = profileModel.getLinkPreviewWhitelist() - 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}) - let settings = localAccountSensitiveSettings.whitelistedUnfurlingSites - - if (!settings) { - settings = {} - } - - // 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) - }) - // Remove any whitelisted sites from app settings that don't exist in the - // whitelist from status-go - Object.keys(settings).forEach(settingsHostname => { - if (!whitelistedHostnames.includes(settingsHostname)) { - delete settings[settingsHostname] - settingsUpdated = true - } - }) - if (settingsUpdated) { - localAccountSensitiveSettings.whitelistedUnfurlingSites = settings - } - } catch (e) { - console.error('Could not parse the whitelist for sites', e) - } - appMain.settingsLoaded() - } - } - Connections { target: chatsModel onNotificationClicked: { @@ -784,8 +719,66 @@ Item { Component.onCompleted: { appView.currentIndex = localAccountSensitiveSettings.lastModeActiveTab - if(!!localAccountSensitiveSettings.lastModeActiveCommunity) + if(!!localAccountSensitiveSettings.lastModeActiveCommunity) { chatsModel.communities.setActiveCommunity(localAccountSensitiveSettings.lastModeActiveCommunity) + } + // Since https://github.com/status-im/status-desktop/commit/93668ff75 + // we're hiding the setting to change appearance for compact normal mode + // of the UI. For now, compact mode is the new default. + // + // Prior to this change, most likely many users are still using the + // normal mode configuration, so we have to enforce compact mode for + // those. + if (!localAccountSensitiveSettings.useCompactMode) { + localAccountSensitiveSettings.useCompactMode = true + } + + const whitelist = profileModel.getLinkPreviewWhitelist() + 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}) + let settings = localAccountSensitiveSettings.whitelistedUnfurlingSites + + if (!settings) { + settings = {} + } + + // 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) + }) + // Remove any whitelisted sites from app settings that don't exist in the + // whitelist from status-go + Object.keys(settings).forEach(settingsHostname => { + if (!whitelistedHostnames.includes(settingsHostname)) { + delete settings[settingsHostname] + settingsUpdated = true + } + }) + if (settingsUpdated) { + localAccountSensitiveSettings.whitelistedUnfurlingSites = settings + } + } catch (e) { + console.error('Could not parse the whitelist for sites', e) + } + appMain.settingsLoaded() } } /*##^## diff --git a/ui/imports/shared/views/chat/LinksMessageView.qml b/ui/imports/shared/views/chat/LinksMessageView.qml index 7422edef2a..43ef956f06 100644 --- a/ui/imports/shared/views/chat/LinksMessageView.qml +++ b/ui/imports/shared/views/chat/LinksMessageView.qml @@ -131,7 +131,7 @@ Column { } return unfurledImageComponent } else { - if (isImageLink && index > 0) { + if (localAccountSensitiveSettings.neverAskAboutUnfurlingAgain || (isImageLink && index > 0)) { return } @@ -157,7 +157,11 @@ Column { } if (linkWhiteListed) { if (fetched) { - return + if (linkData.communityId) { + return invitationBubble + } + + return unfurledLinkComponent } fetched = true @@ -292,7 +296,7 @@ Column { radius: 16 border.width: 1 border.color: Style.current.border - color:Style.current.background + color: Style.current.background StatusFlatRoundButton { anchors.top: parent.top diff --git a/vendor/status-lib b/vendor/status-lib index 4ff2b6857c..f13364388b 160000 --- a/vendor/status-lib +++ b/vendor/status-lib @@ -1 +1 @@ -Subproject commit 4ff2b6857c6af35da2337d729dc2ddf54c2e2c9c +Subproject commit f13364388b01b3aeb2d7bc451f70b516132aa57a