feat: allow to enable/disable telemetry
This commit is contained in:
parent
1315b0534d
commit
f913dce44a
|
@ -37,3 +37,9 @@ method delete*[T](self: Controller[T]) =
|
||||||
|
|
||||||
method init*[T](self: Controller[T]) =
|
method init*[T](self: Controller[T]) =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
|
method toggleTelemetry*[T](self: Controller[T]) =
|
||||||
|
self.settingsService.toggleTelemetry()
|
||||||
|
|
||||||
|
method isTelemetryEnabled*[T](self: Controller[T]): bool =
|
||||||
|
return self.settingsService.isTelemetryEnabled()
|
||||||
|
|
|
@ -9,6 +9,12 @@ method delete*(self: AccessInterface) {.base.} =
|
||||||
method init*(self: AccessInterface) {.base.} =
|
method init*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method toggleTelemetry*(self: AccessInterface) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method isTelemetryEnabled*(self: AccessInterface): bool {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
type
|
type
|
||||||
## Abstract class (concept) which must be implemented by object/s used in this
|
## Abstract class (concept) which must be implemented by object/s used in this
|
||||||
## module.
|
## module.
|
||||||
|
|
|
@ -11,6 +11,9 @@ method load*(self: AccessInterface) {.base.} =
|
||||||
method isLoaded*(self: AccessInterface): bool {.base.} =
|
method isLoaded*(self: AccessInterface): bool {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method toggleTelemetry*(self: AccessInterface) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
# View Delegate Interface
|
# View Delegate Interface
|
||||||
# Delegate for the view must be declared here due to use of QtObject and multi
|
# Delegate for the view must be declared here due to use of QtObject and multi
|
||||||
# inheritance, which is not well supported in Nim.
|
# inheritance, which is not well supported in Nim.
|
||||||
|
|
|
@ -51,7 +51,7 @@ proc newModule*[T](delegate: T,
|
||||||
Module[T] =
|
Module[T] =
|
||||||
result = Module[T]()
|
result = Module[T]()
|
||||||
result.delegate = delegate
|
result.delegate = delegate
|
||||||
result.view = view.newView()
|
result.view = view.newView(result)
|
||||||
result.viewVariant = newQVariant(result.view)
|
result.viewVariant = newQVariant(result.view)
|
||||||
result.controller = controller.newController[Module[T]](result, accountsService, settingsService, profileService, languageService, mnemonicService, privacyService)
|
result.controller = controller.newController[Module[T]](result, accountsService, settingsService, profileService, languageService, mnemonicService, privacyService)
|
||||||
result.moduleLoaded = false
|
result.moduleLoaded = false
|
||||||
|
@ -85,6 +85,8 @@ method load*[T](self: Module[T]) =
|
||||||
self.privacyModule.load()
|
self.privacyModule.load()
|
||||||
self.aboutModule.load()
|
self.aboutModule.load()
|
||||||
|
|
||||||
|
self.view.setIsTelemetryEnabled(self.controller.isTelemetryEnabled())
|
||||||
|
|
||||||
self.moduleLoaded = true
|
self.moduleLoaded = true
|
||||||
self.delegate.profileSectionDidLoad()
|
self.delegate.profileSectionDidLoad()
|
||||||
|
|
||||||
|
@ -93,3 +95,6 @@ method isLoaded*[T](self: Module[T]): bool =
|
||||||
|
|
||||||
method viewDidLoad*(self: Module) =
|
method viewDidLoad*(self: Module) =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
|
method toggleTelemetry*[T](self: Module[T]) =
|
||||||
|
self.controller.toggleTelemetry()
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
import NimQml
|
import NimQml
|
||||||
|
|
||||||
|
import ./io_interface
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type
|
type
|
||||||
View* = ref object of QObject
|
View* = ref object of QObject
|
||||||
|
delegate: io_interface.AccessInterface
|
||||||
|
# TODO: move to the correct module once all have been merged
|
||||||
|
isTelemetryEnabled: bool
|
||||||
|
|
||||||
proc setup(self: View) =
|
proc setup(self: View) =
|
||||||
self.QObject.setup
|
self.QObject.setup
|
||||||
|
@ -10,6 +15,24 @@ QtObject:
|
||||||
proc delete*(self: View) =
|
proc delete*(self: View) =
|
||||||
self.QObject.delete
|
self.QObject.delete
|
||||||
|
|
||||||
proc newView*(): View =
|
proc newView*(delegate: io_interface.AccessInterface): View =
|
||||||
new(result, delete)
|
new(result, delete)
|
||||||
|
result.delegate = delegate
|
||||||
result.setup()
|
result.setup()
|
||||||
|
|
||||||
|
proc isTelemetryEnabledChanged*(self: View) {.signal.}
|
||||||
|
|
||||||
|
proc setIsTelemetryEnabled*(self: View, isTelemetryEnabled: bool) =
|
||||||
|
self.isTelemetryEnabled = isTelemetryEnabled
|
||||||
|
self.isTelemetryEnabledChanged()
|
||||||
|
|
||||||
|
proc getIsTelemetryEnabled*(self: View): QVariant {.slot.} =
|
||||||
|
return newQVariant(self.isTelemetryEnabled)
|
||||||
|
|
||||||
|
QtProperty[QVariant] isTelemetryEnabled:
|
||||||
|
read = getIsTelemetryEnabled
|
||||||
|
notify = isTelemetryEnabledChanged
|
||||||
|
|
||||||
|
proc toggleTelemetry*(self: View) {.slot.} =
|
||||||
|
self.delegate.toggleTelemetry()
|
||||||
|
self.setIsTelemetryEnabled(not self.isTelemetryEnabled)
|
|
@ -75,4 +75,16 @@ method getCurrentNetworkDetails*(self: Service): NetworkDetails =
|
||||||
let networks = getSetting[seq[NetworkDetails]](Setting.Networks_Networks)
|
let networks = getSetting[seq[NetworkDetails]](Setting.Networks_Networks)
|
||||||
for n in networks:
|
for n in networks:
|
||||||
if n.id == currNetwork:
|
if n.id == currNetwork:
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
method toggleTelemetry*(self: Service) =
|
||||||
|
let telemetryServerUrl = status_go_settings.getSetting[string](Setting.TelemetryServerUrl)
|
||||||
|
var newValue = ""
|
||||||
|
if telemetryServerUrl == "":
|
||||||
|
newValue = "https://telemetry.status.im"
|
||||||
|
|
||||||
|
discard status_go_settings.saveSetting(Setting.TelemetryServerUrl, newValue)
|
||||||
|
|
||||||
|
method isTelemetryEnabled*(self: Service): bool =
|
||||||
|
let telemetryServerUrl = status_go_settings.getSetting[string](Setting.TelemetryServerUrl)
|
||||||
|
return telemetryServerUrl != ""
|
|
@ -47,3 +47,9 @@ method setDappsAddress*(self: ServiceInterface, address: string): bool {.base.}
|
||||||
|
|
||||||
method getCurrentNetworkDetails*(self: ServiceInterface): NetworkDetails {.base.} =
|
method getCurrentNetworkDetails*(self: ServiceInterface): NetworkDetails {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method toggleTelemetry*(self: ServiceInterface) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method isTelemetryEnabled*(self: ServiceInterface): bool {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
|
@ -406,6 +406,16 @@ ScrollView {
|
||||||
localAccountSensitiveSettings.stickersEnsRopsten = !localAccountSensitiveSettings.stickersEnsRopsten
|
localAccountSensitiveSettings.stickersEnsRopsten = !localAccountSensitiveSettings.stickersEnsRopsten
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: replace with StatusQ component
|
||||||
|
StatusSettingsLineButton {
|
||||||
|
text: qsTr("Enable Telemetry")
|
||||||
|
isSwitch: true
|
||||||
|
switchChecked: root.store.profileModuleInst.isTelemetryEnabled
|
||||||
|
onClicked: {
|
||||||
|
openPopup(enableTelemetryConfirmationDialogComponent, {light: false})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworksModal {
|
NetworksModal {
|
||||||
|
@ -416,6 +426,24 @@ ScrollView {
|
||||||
id: fleetModal
|
id: fleetModal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: enableTelemetryConfirmationDialogComponent
|
||||||
|
ConfirmationDialog {
|
||||||
|
property bool mode: false
|
||||||
|
|
||||||
|
id: confirmDialog
|
||||||
|
showCancelButton: true
|
||||||
|
confirmationText: qsTr("Are you sure you want to enable telemetry? This will reduce your privacy level while using Status. You need to restart the app for this change to take effect.")
|
||||||
|
onConfirmButtonClicked: {
|
||||||
|
root.store.profileModuleInst.toggleTelemetry()
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
onCancelButtonClicked: {
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ConfirmationDialog {
|
ConfirmationDialog {
|
||||||
id: confirmationPopup
|
id: confirmationPopup
|
||||||
property string settingsProp: ""
|
property string settingsProp: ""
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1aba03aed619b605a2f41eb02765d65756fff817
|
Subproject commit 5417274a3bb83645725bdc9dcad3e6d5af4b269c
|
Loading…
Reference in New Issue