From 1ff424aea19567b8bc66823070abff1f9388460a Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 29 Apr 2024 16:37:22 -0400 Subject: [PATCH] chore: disable history archive for new user and add advanced setting Fixes #14534 --- .../profile_section/advanced/controller.nim | 9 +++++++++ .../profile_section/advanced/io_interface.nim | 9 +++++++++ .../main/profile_section/advanced/module.nim | 11 +++++++++++ .../main/profile_section/advanced/view.nim | 13 +++++++++++++ src/app_service/common/network_constants.nim | 2 +- src/app_service/service/accounts/service.nim | 2 +- .../service/node_configuration/service.nim | 18 ++++++++++-------- src/backend/node_config.nim | 7 +++++++ .../Communities/controls/Options.qml | 11 ++++++++++- ui/app/AppLayouts/Profile/ProfileLayout.qml | 1 - .../Profile/stores/AdvancedStore.qml | 12 ++++++++++++ .../AppLayouts/Profile/views/AdvancedView.qml | 11 +++++++++++ .../AppLayouts/Profile/views/MessagingView.qml | 1 - 13 files changed, 94 insertions(+), 13 deletions(-) diff --git a/src/app/modules/main/profile_section/advanced/controller.nim b/src/app/modules/main/profile_section/advanced/controller.nim index bc17b7e714..69d11952ed 100644 --- a/src/app/modules/main/profile_section/advanced/controller.nim +++ b/src/app/modules/main/profile_section/advanced/controller.nim @@ -142,3 +142,12 @@ proc toggleCommunitySection*(self: Controller) = proc toggleNodeManagementSection*(self: Controller) = self.events.emit(TOGGLE_SECTION, ToggleSectionArgs(sectionType: SectionType.NodeManagement)) + +proc isCommunityHistoryArchiveSupportEnabled*(self: Controller): bool = + self.nodeConfigurationService.isCommunityHistoryArchiveSupportEnabled() + +proc enableCommunityHistoryArchiveSupport*(self: Controller): bool = + self.nodeConfigurationService.enableCommunityHistoryArchiveSupport() + +proc disableCommunityHistoryArchiveSupport*(self: Controller): bool = + self.nodeConfigurationService.disableCommunityHistoryArchiveSupport() diff --git a/src/app/modules/main/profile_section/advanced/io_interface.nim b/src/app/modules/main/profile_section/advanced/io_interface.nim index a771a993c7..73cdd03d5b 100644 --- a/src/app/modules/main/profile_section/advanced/io_interface.nim +++ b/src/app/modules/main/profile_section/advanced/io_interface.nim @@ -69,6 +69,15 @@ method isDebugEnabled*(self: AccessInterface): bool {.base.} = method isRuntimeLogLevelSet*(self: AccessInterface): bool {.base.} = raise newException(ValueError, "No implementation available") +method isCommunityHistoryArchiveSupportEnabled*(self: AccessInterface): bool {.base.} = + raise newException(ValueError, "No implementation available") + +method enableCommunityHistoryArchiveSupport*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method disableCommunityHistoryArchiveSupport*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + method toggleDebug*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/profile_section/advanced/module.nim b/src/app/modules/main/profile_section/advanced/module.nim index 4616495fe2..f0c80c881e 100644 --- a/src/app/modules/main/profile_section/advanced/module.nim +++ b/src/app/modules/main/profile_section/advanced/module.nim @@ -117,6 +117,17 @@ method onNimbusProxyToggled*(self: Module) = method isRuntimeLogLevelSet*(self: Module): bool = return constants.runtimeLogLevelSet() +method isCommunityHistoryArchiveSupportEnabled*(self: Module): bool = + return self.controller.isCommunityHistoryArchiveSupportEnabled() + +method enableCommunityHistoryArchiveSupport*(self: Module) = + if self.controller.enableCommunityHistoryArchiveSupport(): + self.view.archiveProtocolEnabledChanged() + +method disableCommunityHistoryArchiveSupport*(self: Module) = + if self.controller.disableCommunityHistoryArchiveSupport(): + self.view.archiveProtocolEnabledChanged() + method toggleWalletSection*(self: Module) = self.controller.toggleWalletSection() diff --git a/src/app/modules/main/profile_section/advanced/view.nim b/src/app/modules/main/profile_section/advanced/view.nim index ef822e6137..cf00fc9b3a 100644 --- a/src/app/modules/main/profile_section/advanced/view.nim +++ b/src/app/modules/main/profile_section/advanced/view.nim @@ -103,6 +103,19 @@ QtObject: QtProperty[bool] isRuntimeLogLevelSet: read = getIsRuntimeLogLevelSet + proc archiveProtocolEnabledChanged*(self: View) {.signal.} + proc getArchiveProtocolEnabled*(self: View): bool {.slot.} = + return self.delegate.isCommunityHistoryArchiveSupportEnabled() + QtProperty[bool] archiveProtocolEnabled: + read = getArchiveProtocolEnabled + notify = archiveProtocolEnabledChanged + + proc enableCommunityHistoryArchiveSupport*(self: View) {.slot.} = + self.delegate.enableCommunityHistoryArchiveSupport() + + proc disableCommunityHistoryArchiveSupport*(self: View) {.slot.} = + self.delegate.disableCommunityHistoryArchiveSupport() + proc toggleWalletSection*(self: View) {.slot.} = self.delegate.toggleWalletSection() diff --git a/src/app_service/common/network_constants.nim b/src/app_service/common/network_constants.nim index 9500004607..d7da23a7cf 100644 --- a/src/app_service/common/network_constants.nim +++ b/src/app_service/common/network_constants.nim @@ -264,7 +264,7 @@ var NODE_CONFIG* = %* { }, "Networks": NETWORKS, "TorrentConfig": { - "Enabled": true, + "Enabled": false, "Port": TORRENT_CONFIG_PORT, "DataDir": DEFAULT_TORRENT_CONFIG_DATADIR, "TorrentDir": DEFAULT_TORRENT_CONFIG_TORRENTDIR diff --git a/src/app_service/service/accounts/service.nim b/src/app_service/service/accounts/service.nim index 34aeb3494d..c4f69873e7 100644 --- a/src/app_service/service/accounts/service.nim +++ b/src/app_service/service/accounts/service.nim @@ -394,7 +394,7 @@ QtObject: logLevel: some(toStatusGoSupportedLogLevel(main_constants.LOG_LEVEL)), wakuV2LightClient: false, previewPrivacy: true, - torrentConfigEnabled: some(true), + torrentConfigEnabled: some(false), torrentConfigPort: some(TORRENT_CONFIG_PORT), walletSecretsConfig: self.buildWalletSecrets(), ) diff --git a/src/app_service/service/node_configuration/service.nim b/src/app_service/service/node_configuration/service.nim index f5de8e16d2..bda53d0a58 100644 --- a/src/app_service/service/node_configuration/service.nim +++ b/src/app_service/service/node_configuration/service.nim @@ -56,14 +56,6 @@ proc adaptNodeSettingsForTheAppNeed(self: Service) = self.configuration.LogFile = "./geth.log" self.configuration.ShhextConfig.BackupDisabledDataDir = "./" - if (not self.isCommunityHistoryArchiveSupportEnabled()): - # Force community archive support true on Desktop - # TODO those lines can be removed in the future once we are sure no one has used a legacy client where it is off - if (self.enableCommunityHistoryArchiveSupport()): - self.configuration.TorrentConfig.Enabled = true - else: - error "Setting Community History Archive On failed" - proc init*(self: Service) = try: let response = status_node_config.getNodeConfig() @@ -123,6 +115,16 @@ proc enableCommunityHistoryArchiveSupport*(self: Service): bool = error "error enabling community history archive support: ", errDescription = response.error.message return false + self.configuration.TorrentConfig.Enabled = true + return true + +proc disableCommunityHistoryArchiveSupport*(self: Service): bool = + let response = status_node_config.disableCommunityHistoryArchiveSupport() + if(not response.error.isNil): + error "error disabling community history archive support: ", errDescription = response.error.message + return false + + self.configuration.TorrentConfig.Enabled = false return true proc getFleet*(self: Service): Fleet = diff --git a/src/backend/node_config.nim b/src/backend/node_config.nim index 90a0cd08a2..02d5727965 100644 --- a/src/backend/node_config.nim +++ b/src/backend/node_config.nim @@ -33,4 +33,11 @@ proc enableCommunityHistoryArchiveSupport*(): RpcResponse[JsonNode] = result = core.callPrivateRPC("enableCommunityHistoryArchiveProtocol".prefix) except RpcException as e: error "error doing rpc request", methodName = "enableCommunityHistoryArchiveProtocol", exception=e.msg + raise newException(RpcException, e.msg) + +proc disableCommunityHistoryArchiveSupport*(): RpcResponse[JsonNode] = + try: + result = core.callPrivateRPC("disableCommunityHistoryArchiveProtocol".prefix) + except RpcException as e: + error "error doing rpc request", methodName = "disableCommunityHistoryArchiveProtocol", exception=e.msg raise newException(RpcException, e.msg) \ No newline at end of file diff --git a/ui/app/AppLayouts/Communities/controls/Options.qml b/ui/app/AppLayouts/Communities/controls/Options.qml index 9203347e1c..a4c056d99c 100644 --- a/ui/app/AppLayouts/Communities/controls/Options.qml +++ b/ui/app/AppLayouts/Communities/controls/Options.qml @@ -31,11 +31,20 @@ ColumnLayout { StatusCheckBox { id: archiveSupportToggle width: (parent.width-12) - checked: true + checked: false leftSide: false padding: 0 anchors.verticalCenter: parent.verticalCenter text: qsTr("Community history service") + + StatusToolTip { + text: qsTr('For this Community Setting to work, you also need to activate "Archive Protocol Enabled" in Advanced Settings') + visible: hoverHandler.hovered + } + HoverHandler { + id: hoverHandler + enabled: true + } } } diff --git a/ui/app/AppLayouts/Profile/ProfileLayout.qml b/ui/app/AppLayouts/Profile/ProfileLayout.qml index 37c6ba98fe..56690ee960 100644 --- a/ui/app/AppLayouts/Profile/ProfileLayout.qml +++ b/ui/app/AppLayouts/Profile/ProfileLayout.qml @@ -230,7 +230,6 @@ StatusSectionLayout { sourceComponent: MessagingView { implicitWidth: parent.width implicitHeight: parent.height - advancedStore: root.store.advancedStore messagingStore: root.store.messagingStore sectionTitle: root.store.getNameForSubsection(Constants.settingsSubsection.messaging) contactsStore: root.store.contactsStore diff --git a/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml b/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml index 5d3b04882a..6e816b6e3b 100644 --- a/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml +++ b/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml @@ -18,6 +18,7 @@ QtObject { readonly property bool isWakuV2ShardedCommunitiesEnabled: localAppSettings.wakuV2ShardedCommunitiesEnabled ?? false property int logMaxBackups: advancedModule ? advancedModule.logMaxBackups : 1 property bool isRuntimeLogLevelSet: advancedModule ? advancedModule.isRuntimeLogLevelSet: false + readonly property bool archiveProtocolEnabled: advancedModule ? advancedModule.archiveProtocolEnabled : false property var customNetworksModel: advancedModule? advancedModule.customNetworksModel : [] @@ -150,6 +151,17 @@ QtObject { localAppSettings.createCommunityEnabled = !localAppSettings.createCommunityEnabled } + function toggleArchiveProtocolEnabled() { + if(!advancedModule) + return + + if (root.archiveProtocolEnabled) { + advancedModule.disableCommunityHistoryArchiveSupport() + } else { + advancedModule.enableCommunityHistoryArchiveSupport() + } + } + function toggleManageCommunityOnTestnet() { root.isManageCommunityOnTestModeEnabled = !root.isManageCommunityOnTestModeEnabled } diff --git a/ui/app/AppLayouts/Profile/views/AdvancedView.qml b/ui/app/AppLayouts/Profile/views/AdvancedView.qml index 0d7948d6b8..51b9834c54 100644 --- a/ui/app/AppLayouts/Profile/views/AdvancedView.qml +++ b/ui/app/AppLayouts/Profile/views/AdvancedView.qml @@ -196,6 +196,17 @@ SettingsContentBase { } ///////////////////////////////////////////////////// + StatusSettingsLineButton { + anchors.leftMargin: 0 + anchors.rightMargin: 0 + text: qsTr("Archive Protocol Enabled") + isSwitch: true + switchChecked: root.advancedStore.archiveProtocolEnabled + onClicked: { + root.advancedStore.toggleArchiveProtocolEnabled() + } + } + Separator { width: parent.width } diff --git a/ui/app/AppLayouts/Profile/views/MessagingView.qml b/ui/app/AppLayouts/Profile/views/MessagingView.qml index 821ce02e8d..424805582a 100644 --- a/ui/app/AppLayouts/Profile/views/MessagingView.qml +++ b/ui/app/AppLayouts/Profile/views/MessagingView.qml @@ -25,7 +25,6 @@ SettingsContentBase { id: root property MessagingStore messagingStore - property AdvancedStore advancedStore property ContactsStore contactsStore ColumnLayout {