fix(settings): fix whitelist setting that starts null

This commit is contained in:
Jonathan Rainville 2021-11-05 11:07:30 -04:00 committed by Iuri Matias
parent 0d7d09e351
commit 499d99a185
3 changed files with 18 additions and 3 deletions

View File

@ -142,6 +142,9 @@ Column {
let linkWhiteListed = false
const linkHostname = Utils.getHostname(link)
if (!localAccountSensitiveSettings.whitelistedUnfurlingSites) {
localAccountSensitiveSettings.whitelistedUnfurlingSites = {}
}
const linkExists = Object.keys(localAccountSensitiveSettings.whitelistedUnfurlingSites).some(function(whitelistedHostname) {
const exists = linkHostname.endsWith(whitelistedHostname)
if (exists) {

View File

@ -23,6 +23,9 @@ ModalPopup {
function populatePreviewableSites() {
let whitelist = JSON.parse(privacyModule.getLinkPreviewWhitelist())
if (!localAccountSensitiveSettings.whitelistedUnfurlingSites) {
localAccountSensitiveSettings.whitelistedUnfurlingSites = {}
}
whitelist.forEach(entry => {
entry.isWhitelisted = localAccountSensitiveSettings.whitelistedUnfurlingSites[entry.address] || false
previewableSites.append(entry)
@ -172,11 +175,16 @@ ModalPopup {
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
onCheckedChanged: function () {
if (localAccountSensitiveSettings.whitelistedUnfurlingSites[address] === this.checked) {
let settings = localAccountSensitiveSettings.whitelistedUnfurlingSites
if (!settings) {
settings = {}
}
if (settings[address] === this.checked) {
return
}
const settings = localAccountSensitiveSettings.whitelistedUnfurlingSites
settings[address] = this.checked
localAccountSensitiveSettings.whitelistedUnfurlingSites = settings
}

View File

@ -527,7 +527,11 @@ Item {
// 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 = localAccountSensitiveSettings.whitelistedUnfurlingSites
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]) {