Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-picks of hide create community button and disable archive #14565

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/app/global/local_app_settings.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ const LAS_KEY_CUSTOM_MOUSE_SCROLLING_ENABLED = "global/custom_mouse_scroll_enabl
const DEFAULT_CUSTOM_MOUSE_SCROLLING_ENABLED = false
const DEFAULT_VISIBILITY = 2 #windowed visibility, from qml
const LAS_KEY_FAKE_LOADING_SCREEN_ENABLED = "global/fake_loading_screen"
const LAS_KEY_CREATE_COMMUNITIES_ENABLED = "global/create_communities"
let DEFAULT_FAKE_LOADING_SCREEN_ENABLED = defined(production) and not TEST_MODE_ENABLED #enabled in production, disabled in development and e2e tests
const LAS_KEY_SHARDED_COMMUNITIES_ENABLED = "global/sharded_communities"
const DEFAULT_LAS_KEY_SHARDED_COMMUNITIES_ENABLED = false
const LAS_KEY_TRANSLATIONS_ENABLED = "global/translations_enabled"
const DEFAULT_LAS_KEY_TRANSLATIONS_ENABLED = false
const DEFAULT_LAS_KEY_CREATE_COMMUNITIES_ENABLED = false

QtObject:
type LocalAppSettings* = ref object of QObject
Expand Down Expand Up @@ -148,6 +150,19 @@ QtObject:
write = setFakeLoadingScreenEnabled
notify = fakeLoadingScreenEnabledChanged

proc createCommunityEnabledChanged*(self: LocalAppSettings) {.signal.}
proc getCreateCommunityEnabled*(self: LocalAppSettings): bool {.slot.} =
self.settings.value(LAS_KEY_CREATE_COMMUNITIES_ENABLED, newQVariant(DEFAULT_LAS_KEY_CREATE_COMMUNITIES_ENABLED)).boolVal

proc setCreateCommunityEnabled*(self: LocalAppSettings, enabled: bool) {.slot.} =
self.settings.setValue(LAS_KEY_CREATE_COMMUNITIES_ENABLED, newQVariant(enabled))
self.createCommunityEnabledChanged()

QtProperty[bool] createCommunityEnabled:
read = getCreateCommunityEnabled
write = setCreateCommunityEnabled
notify = createCommunityEnabledChanged

proc wakuV2ShardedCommunitiesEnabledChanged*(self: LocalAppSettings) {.signal.}
proc getWakuV2ShardedCommunitiesEnabled*(self: LocalAppSettings): bool {.slot.} =
self.settings.value(LAS_KEY_SHARDED_COMMUNITIES_ENABLED, newQVariant(DEFAULT_LAS_KEY_SHARDED_COMMUNITIES_ENABLED)).boolVal
Expand Down
9 changes: 9 additions & 0 deletions src/app/modules/main/profile_section/advanced/controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
11 changes: 11 additions & 0 deletions src/app/modules/main/profile_section/advanced/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
13 changes: 13 additions & 0 deletions src/app/modules/main/profile_section/advanced/view.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion src/app_service/common/network_constants.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app_service/service/accounts/service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
Expand Down
18 changes: 10 additions & 8 deletions src/app_service/service/node_configuration/service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 =
Expand Down
7 changes: 7 additions & 0 deletions src/backend/node_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
20 changes: 12 additions & 8 deletions ui/app/AppLayouts/Communities/CommunitiesPortalLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,18 @@ StatusSectionLayout {
onClicked: Global.importCommunityPopupRequested()
}

StatusButton {
id: createBtn
objectName: "createCommunityButton"
Layout.preferredHeight: 38
verticalPadding: 0
text: qsTr("Create community")
onClicked: {
Global.openPopup(chooseCommunityCreationTypePopupComponent)
Loader {
Layout.preferredHeight: active ? 38 : 0
active: communitiesStore.createCommunityEnabled || communitiesStore.testEnvironment
sourceComponent: StatusButton {
id: createBtn
objectName: "createCommunityButton"
height: parent.height
verticalPadding: 0
text: qsTr("Create community")
onClicked: {
Global.openPopup(chooseCommunityCreationTypePopupComponent)
}
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion ui/app/AppLayouts/Communities/controls/Options.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions ui/app/AppLayouts/Communities/stores/CommunitiesStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ QtObject {
property bool downloadingCommunityHistoryArchives: root.communitiesModuleInst.downloadingCommunityHistoryArchives
property var advancedModule: profileSectionModule.advancedModule

readonly property bool createCommunityEnabled: localAppSettings.createCommunityEnabled ?? false
readonly property bool testEnvironment: localAppSettings.testEnvironment ?? false

// TODO: Could the backend provide directly 2 filtered models??
//property var featuredCommunitiesModel: root.communitiesModuleInst.curatedFeaturedCommunities
//property var popularCommunitiesModel: root.communitiesModuleInst.curatedPopularCommunities
Expand Down
1 change: 0 additions & 1 deletion ui/app/AppLayouts/Profile/ProfileLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions ui/app/AppLayouts/Profile/stores/AdvancedStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ 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 : []

readonly property bool isFakeLoadingScreenEnabled: localAppSettings.fakeLoadingScreenEnabled ?? false
readonly property bool createCommunityEnabled: localAppSettings.createCommunityEnabled ?? false
property bool isManageCommunityOnTestModeEnabled: false
readonly property QtObject experimentalFeatures: QtObject {
readonly property string browser: "browser"
Expand Down Expand Up @@ -142,6 +144,24 @@ QtObject {
localAppSettings.fakeLoadingScreenEnabled = !localAppSettings.fakeLoadingScreenEnabled
}

function toggleCreateCommunityEnabled() {
if(!localAppSettings)
return

localAppSettings.createCommunityEnabled = !localAppSettings.createCommunityEnabled
}

function toggleArchiveProtocolEnabled() {
if(!advancedModule)
return

if (root.archiveProtocolEnabled) {
advancedModule.disableCommunityHistoryArchiveSupport()
} else {
advancedModule.enableCommunityHistoryArchiveSupport()
}
}

function toggleManageCommunityOnTestnet() {
root.isManageCommunityOnTestModeEnabled = !root.isManageCommunityOnTestModeEnabled
}
Expand Down
22 changes: 22 additions & 0 deletions ui/app/AppLayouts/Profile/views/AdvancedView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ SettingsContentBase {

/////////////////////////////////////////////////////
// WalletConnect POC - to remove
StatusSettingsLineButton {
anchors.leftMargin: 0
anchors.rightMargin: 0
text: qsTr("Enable Community Creation")
isSwitch: true
switchChecked: root.advancedStore.createCommunityEnabled
onClicked: {
root.advancedStore.toggleCreateCommunityEnabled()
}
}

StatusSettingsLineButton {
anchors.leftMargin: 0
anchors.rightMargin: 0
Expand All @@ -185,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
}
Expand Down
1 change: 0 additions & 1 deletion ui/app/AppLayouts/Profile/views/MessagingView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ SettingsContentBase {
id: root

property MessagingStore messagingStore
property AdvancedStore advancedStore
property ContactsStore contactsStore

ColumnLayout {
Expand Down