chore: disable history archive for new user and add advanced setting

Fixes #14534
This commit is contained in:
Jonathan Rainville 2024-04-29 16:37:22 -04:00
parent bfb506540f
commit 1ff424aea1
13 changed files with 94 additions and 13 deletions

View File

@ -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()

View File

@ -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")

View File

@ -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()

View File

@ -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()

View File

@ -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

View File

@ -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(),
)

View File

@ -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 =

View File

@ -34,3 +34,10 @@ proc enableCommunityHistoryArchiveSupport*(): RpcResponse[JsonNode] =
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)

View File

@ -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
}
}
}

View File

@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -25,7 +25,6 @@ SettingsContentBase {
id: root
property MessagingStore messagingStore
property AdvancedStore advancedStore
property ContactsStore contactsStore
ColumnLayout {