mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-18 01:27:25 +00:00
Update MessagingView.qml
Group all common functions
This commit is contained in:
parent
f20c5efe20
commit
d23cce99a0
@ -33,6 +33,39 @@ SettingsContentBase {
|
|||||||
spacing: 2 * Constants.settingsSection.itemSpacing
|
spacing: 2 * Constants.settingsSection.itemSpacing
|
||||||
width: root.contentWidth
|
width: root.contentWidth
|
||||||
|
|
||||||
|
function switchOffPreviewableSites() {
|
||||||
|
//update all models
|
||||||
|
localAccountSensitiveSettings.displayChatImages = false
|
||||||
|
for (let i = 0; i < previewableSites.count; i++) {
|
||||||
|
let item = previewableSites.get(i)
|
||||||
|
RootStore.updateWhitelistedUnfurlingSites(item.address, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildPreviewablesSitesJSON() {
|
||||||
|
let whitelistAsString = root.messagingStore.getLinkPreviewWhitelist()
|
||||||
|
if(whitelistAsString == "")
|
||||||
|
return
|
||||||
|
|
||||||
|
if (!localAccountSensitiveSettings.whitelistedUnfurlingSites) {
|
||||||
|
localAccountSensitiveSettings.whitelistedUnfurlingSites = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
let anyWhitelisted = false
|
||||||
|
let whitelist = JSON.parse(whitelistAsString)
|
||||||
|
whitelist.forEach(entry => {
|
||||||
|
entry.isWhitelisted = !!localAccountSensitiveSettings.whitelistedUnfurlingSites[entry.address]
|
||||||
|
if(entry.isWhitelisted) anyWhitelisted = true
|
||||||
|
})
|
||||||
|
return [anyWhitelisted, whitelist]
|
||||||
|
}
|
||||||
|
|
||||||
|
function populatePreviewableSites() {
|
||||||
|
const [anyWhitelisted, whitelist] = buildPreviewablesSitesJSON()
|
||||||
|
previewableSites.populateModel(whitelist)
|
||||||
|
previewableSites.anyWhitelisted = anyWhitelisted
|
||||||
|
}
|
||||||
|
|
||||||
ButtonGroup {
|
ButtonGroup {
|
||||||
id: showProfilePictureToGroup
|
id: showProfilePictureToGroup
|
||||||
}
|
}
|
||||||
@ -136,18 +169,10 @@ SettingsContentBase {
|
|||||||
components: [
|
components: [
|
||||||
StatusSwitch {
|
StatusSwitch {
|
||||||
id: showMessageLinksSwitch
|
id: showMessageLinksSwitch
|
||||||
function switchOffPreviewableSites() {
|
|
||||||
//update all models
|
|
||||||
localAccountSensitiveSettings.displayChatImages = false
|
|
||||||
for (let i = 0; i < previewableSites.count; i++) {
|
|
||||||
let item = previewableSites.get(i)
|
|
||||||
RootStore.updateWhitelistedUnfurlingSites(item.address, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
checked: previewableSites.anyWhitelisted || localAccountSensitiveSettings.displayChatImages
|
checked: previewableSites.anyWhitelisted || localAccountSensitiveSettings.displayChatImages
|
||||||
onToggled: {
|
onToggled: {
|
||||||
if (checked === false) {
|
if (!checked) {
|
||||||
switchOffPreviewableSites()
|
generalColumn.switchOffPreviewableSites()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,35 +180,11 @@ SettingsContentBase {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
showMessageLinksSwitch.toggle()
|
showMessageLinksSwitch.toggle()
|
||||||
if (!showMessageLinksSwitch.checked) {
|
if (!showMessageLinksSwitch.checked) {
|
||||||
showMessageLinksSwitch.switchOffPreviewableSites()
|
generalColumn.switchOffPreviewableSites()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildPreviewablesSitesJSON() {
|
|
||||||
let whitelistAsString = root.messagingStore.getLinkPreviewWhitelist()
|
|
||||||
if(whitelistAsString == "")
|
|
||||||
return
|
|
||||||
|
|
||||||
if (!localAccountSensitiveSettings.whitelistedUnfurlingSites) {
|
|
||||||
localAccountSensitiveSettings.whitelistedUnfurlingSites = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
let anyWhitelisted = false
|
|
||||||
let whitelist = JSON.parse(whitelistAsString)
|
|
||||||
whitelist.forEach(entry => {
|
|
||||||
entry.isWhitelisted = !!localAccountSensitiveSettings.whitelistedUnfurlingSites[entry.address]
|
|
||||||
if(entry.isWhitelisted) anyWhitelisted = true
|
|
||||||
})
|
|
||||||
return [anyWhitelisted, whitelist]
|
|
||||||
}
|
|
||||||
|
|
||||||
function populatePreviewableSites() {
|
|
||||||
const [anyWhitelisted, whitelist] = buildPreviewablesSitesJSON()
|
|
||||||
previewableSites.populateModel(whitelist)
|
|
||||||
previewableSites.anyWhitelisted = anyWhitelisted
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
populatePreviewableSites()
|
populatePreviewableSites()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user