feat: show whitelistable sites in the settings and set in qt settings

This commit is contained in:
Jonathan Rainville 2020-10-23 13:57:28 -04:00 committed by Iuri Matias
parent 4f81032f5e
commit a679758230
6 changed files with 73 additions and 16 deletions

View File

@ -1,4 +1,4 @@
import NimQml, sequtils, strutils, sugar, os import NimQml, sequtils, strutils, sugar, os, json
import views/[mailservers_list, ens_manager, contact_list, profile_info, device_list, dapp_list] import views/[mailservers_list, ens_manager, contact_list, profile_info, device_list, dapp_list]
import ../../status/profile/[mailserver, profile, devices] import ../../status/profile/[mailserver, profile, devices]
import ../../status/profile as status_profile import ../../status/profile as status_profile
@ -327,3 +327,6 @@ QtObject:
self.status.contacts.removeContact(publicKey) self.status.contacts.removeContact(publicKey)
self.contactChanged(publicKey, false) self.contactChanged(publicKey, false)
proc getLinkPreviewWhitelist*(self: ProfileView): string {.slot.} =
result = $(self.status.profile.getLinkPreviewWhitelist())

View File

@ -66,3 +66,6 @@ proc getCurrentNetworkDetails*(): NetworkDetails =
let currNetwork = getSetting[string](Setting.Networks_CurrentNetwork, constants.DEFAULT_NETWORK_NAME) let currNetwork = getSetting[string](Setting.Networks_CurrentNetwork, constants.DEFAULT_NETWORK_NAME)
let networks = getSetting[seq[NetworkDetails]](Setting.Networks_Networks) let networks = getSetting[seq[NetworkDetails]](Setting.Networks_Networks)
networks.find((network: NetworkDetails) => network.id == currNetwork) networks.find((network: NetworkDetails) => network.id == currNetwork)
proc getLinkPreviewWhitelist*(): JsonNode =
result = callPrivateRPC("getLinkPreviewWhitelist".prefix, %* []).parseJSON()["result"]

View File

@ -3,6 +3,7 @@ import libstatus/types
import profile/profile import profile/profile
import libstatus/core as libstatus_core import libstatus/core as libstatus_core
import libstatus/accounts as status_accounts import libstatus/accounts as status_accounts
import libstatus/settings as status_settings
import ../eventemitter import ../eventemitter
type type
@ -13,3 +14,6 @@ proc newProfileModel*(): ProfileModel =
proc logout*(self: ProfileModel) = proc logout*(self: ProfileModel) =
discard status_accounts.logout() discard status_accounts.logout()
proc getLinkPreviewWhitelist*(self: ProfileModel): JsonNode =
result = status_settings.getLinkPreviewWhitelist()

View File

@ -12,13 +12,32 @@ Item {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
ListModel {
id: previewableSites
}
Component.onCompleted: {
const sites = profileModel.getLinkPreviewWhitelist()
try {
const sitesJSON = JSON.parse(sites)
sitesJSON.forEach(function (site) {
previewableSites.append(site)
})
} catch (e) {
console.error(e)
}
}
property Component dappListPopup: DappList { property Component dappListPopup: DappList {
onClosed: destroy() onClosed: destroy()
} }
Item {
id: profileImgNameContainer Column {
id: containerColumn
spacing: Style.current.padding
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: Style.current.padding
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: contentMargin anchors.rightMargin: contentMargin
anchors.left: parent.left anchors.left: parent.left
@ -29,13 +48,10 @@ Item {
id: labelSecurity id: labelSecurity
//% "Security" //% "Security"
text: qsTrId("security") text: qsTrId("security")
anchors.top: parent.top
} }
Item { Item {
id: backupSeedPhrase id: backupSeedPhrase
anchors.top: labelSecurity.bottom
anchors.topMargin: Style.current.padding
height: backupText.height height: backupText.height
width: parent.width width: parent.width
@ -77,11 +93,13 @@ Item {
id: backupSeedModal id: backupSeedModal
} }
Separator {
id: separator
Layout.topMargin: Style.current.bigPadding - containerColumn.spacing
}
Item { Item {
id: dappPermissions id: dappPermissions
anchors.top: backupSeedPhrase.bottom
anchors.topMargin: Style.current.padding
height: dappPermissionsText.height height: dappPermissionsText.height
width: parent.width width: parent.width
@ -117,22 +135,18 @@ Item {
} }
Separator { Separator {
id: separator id: separator2
anchors.top: dappPermissions.bottom Layout.topMargin: Style.current.bigPadding - containerColumn.spacing
anchors.topMargin: Style.current.bigPadding
} }
StatusSectionHeadline { StatusSectionHeadline {
id: labelPrivacy id: labelPrivacy
//% "Privacy" //% "Privacy"
text: qsTrId("privacy") text: qsTrId("privacy")
anchors.top: separator.bottom
} }
RowLayout { RowLayout {
id: displayImageSettings id: displayImageSettings
anchors.top: labelPrivacy.bottom
anchors.topMargin: Style.current.padding
StyledText { StyledText {
//% "Display images in chat automatically" //% "Display images in chat automatically"
text: qsTrId("display-images-in-chat-automatically") text: qsTrId("display-images-in-chat-automatically")
@ -148,6 +162,38 @@ Item {
text: qsTrId("under-development") text: qsTrId("under-development")
} }
} }
StatusSectionHeadline {
id: labelURLUnfurling
text: qsTr("URL Previews")
}
ListView {
id: sitesListView
width: parent.width
model: previewableSites
interactive: false
height: childrenRect.height
delegate: Component {
RowLayout {
id: displayYoutubeSettings
StyledText {
text: qsTr("Display %1 previews").arg(title)
}
StatusSwitch {
checked: !!appSettings.whitelistedUnfurlingSites[address]
onCheckedChanged: function () {
appSettings.whitelistedUnfurlingSites[address] = this.checked
}
}
StyledText {
//% "under development"
text: qsTrId("under-development")
}
}
}
}
} }
} }

View File

@ -81,6 +81,7 @@ ApplicationWindow {
property real volume: 0.2 property real volume: 0.2
property int notificationSetting: 0 property int notificationSetting: 0
property bool notificationSoundsEnabled: true property bool notificationSoundsEnabled: true
property var whitelistedUnfurlingSites: ({})
// Browser settings // Browser settings
property bool autoLoadImages: true property bool autoLoadImages: true

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit efbf093bc494e9c3ea00a6a3e8f286826294dff7 Subproject commit d04e54e54e8ea85c9bd35aff5482e064f5ee76b0