From a5d48a20b327e32806b04f1ed7ff4effd37a890f Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Mon, 6 Sep 2021 18:31:10 -0400 Subject: [PATCH] feat: wakuV2 light client mode --- src/app/node/view.nim | 16 ++++ .../Profile/Sections/AdvancedContainer.qml | 75 +++++++++++++++++++ vendor/status-lib | 2 +- 3 files changed, 92 insertions(+), 1 deletion(-) diff --git a/src/app/node/view.nim b/src/app/node/view.nim index b2c14419f9..d8c9af3a6a 100644 --- a/src/app/node/view.nim +++ b/src/app/node/view.nim @@ -38,6 +38,7 @@ QtObject: stats*: Stats peerSize: int bloomBitsSet: int + wakuV2LightClient: bool proc setup(self: NodeView) = self.QObject.setup @@ -50,6 +51,7 @@ QtObject: result.lastMessage = "" result.wakuBloomFilterMode = false result.fullNode = false + result.wakuV2LightClient = false result.setup proc delete*(self: NodeView) = @@ -124,6 +126,7 @@ QtObject: let nodeConfig = self.status.settings.getNodeConfig() self.wakuBloomFilterMode = self.status.settings.getSetting[:bool](Setting.WakuBloomFilterMode) self.fullNode = nodeConfig["WakuConfig"]["FullNode"].getBool() + self.wakuV2LightClient = nodeConfig["WakuV2Config"]{"LightClient"}.getBool() self.initialized() proc wakuVersion*(self: NodeView): int {.slot.} = @@ -202,3 +205,16 @@ QtObject: notify = peerSizeChanged proc log*(self: NodeView, logContent: string) {.signal.} + + proc getWakuV2LightClient(self: NodeView): bool {.slot.} = self.wakuV2LightClient + + QtProperty[bool] WakuV2LightClient: + read = getWakuV2LightClient + notify = initialized + + proc setWakuV2LightClient*(self: NodeView, enabled: bool) {.slot.} = + let statusGoResult = self.status.settings.setV2LightMode(enabled) + if statusGoResult.error != "": + error "Error saving updated node config", msg=statusGoResult.error + else: + quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported diff --git a/ui/app/AppLayouts/Profile/Sections/AdvancedContainer.qml b/ui/app/AppLayouts/Profile/Sections/AdvancedContainer.qml index 2d79fd7eb2..9ffc88f8db 100644 --- a/ui/app/AppLayouts/Profile/Sections/AdvancedContainer.qml +++ b/ui/app/AppLayouts/Profile/Sections/AdvancedContainer.qml @@ -12,6 +12,7 @@ ScrollView { width: parent.width contentHeight: advancedContainer.height + 100 clip: true + property bool isWakuV2: profileModel.fleets.fleet == Constants.waku_prod || profileModel.fleets.fleet === Constants.waku_test Item { id: advancedContainer @@ -201,6 +202,7 @@ ScrollView { } StatusSectionHeadline { + visible: !isWakuV2 //% "Bloom filter level" text: qsTrId("bloom-filter-level") topPadding: Style.current.bigPadding @@ -208,6 +210,7 @@ ScrollView { } Row { + visible: !isWakuV2 spacing: 11 Component { @@ -284,6 +287,78 @@ ScrollView { } } + StatusSectionHeadline { + visible: isWakuV2 + text: qsTr("WakuV2 mode") + topPadding: Style.current.bigPadding + bottomPadding: Style.current.padding + } + + Row { + spacing: 11 + visible: isWakuV2 + Component { + id: wakuV2ModeConfirmationDialogComponent + ConfirmationDialog { + property bool mode: false + + id: confirmDialog + //% "Warning!" + title: qsTrId("close-app-title") + //% "The account will be logged out. When you login again, the selected mode will be enabled" + confirmationText: qsTrId("the-account-will-be-logged-out--when-you-login-again--the-selected-mode-will-be-enabled") + onConfirmButtonClicked: { + nodeModel.setWakuV2LightClient(mode) + } + onClosed: { + if(nodeModel.WakuV2LightClient){ + btnWakuV2Light.click() + } else { + btnWakuV2Full.click(); + } + destroy() + } + } + } + + ButtonGroup { + id: wakuV2Group + } + + BloomSelectorButton { + id: btnWakuV2Light + buttonGroup: wakuV2Group + checkedByDefault: nodeModel.WakuV2LightClient + //% "Light Node" + btnText: qsTrId("light-node") + onToggled: { + if (!nodeModel.WakuV2LightClient) { + openPopup(wakuV2ModeConfirmationDialogComponent, {light: true}) + } else { + btnWakuV2Light.click() + } + } + } + + BloomSelectorButton { + id: btnWakuV2Full + buttonGroup: wakuV2Group + checkedByDefault: !nodeModel.WakuV2LightClient + //% "Full Node" + btnText: qsTrId("full-node") + onToggled: { + if (nodeModel.WakuV2LightClient) { + openPopup(wakuV2ModeConfirmationDialogComponent, {light: false}) + } else { + btnWakuV2Full.click() + } + } + } + } + + + + StatusSettingsLineButton { text: qsTr("Download messages") isSwitch: true diff --git a/vendor/status-lib b/vendor/status-lib index a80869872d..8fe7a571bf 160000 --- a/vendor/status-lib +++ b/vendor/status-lib @@ -1 +1 @@ -Subproject commit a80869872d822bdc239cc67f98c6fb3a7f54febe +Subproject commit 8fe7a571bf3600e280a60dc776843236baeea9ff