chore(Global): Remove FeatureFlags access via Global singleton

- rationale: do not save global state in a singleton, gather and
propagate the values via FeatureFlagsStore

Fixes #14697
This commit is contained in:
Lukáš Tinkl 2024-08-12 12:41:27 +02:00 committed by Lukáš Tinkl
parent 20f30a52fd
commit a7e74f3e00
10 changed files with 41 additions and 20 deletions

View File

@ -1,10 +0,0 @@
// Mock of src/app/global/feature_flags.nim
import QtQuick 2.15
QtObject {
readonly property string contextPropertyName: "featureFlagsRootContextProperty"
//
// Silence warnings
readonly property bool dappsEnabled: true
}

View File

@ -32,6 +32,9 @@ Item {
property var networkConnectionStore
property bool appMainVisible
property bool dappsEnabled
property bool swapEnabled
onAppMainVisibleChanged: {
resetView()
}
@ -215,6 +218,9 @@ Item {
sendModal: root.sendModalPopup
networkConnectionStore: root.networkConnectionStore
dappsEnabled: root.dappsEnabled
swapEnabled: root.swapEnabled
headerButton.text: RootStore.overview.ens || StatusQUtils.Utils.elideAndFormatWalletAddress(RootStore.overview.mixedcaseAddress)
headerButton.visible: !RootStore.overview.isAllAccounts
onLaunchShareAddressModal: Global.openShowQRPopup({
@ -292,6 +298,7 @@ Item {
height: visible ? 61: implicitHeight
walletStore: RootStore
transactionStore: root.transactionStore
swapEnabled: root.swapEnabled
networkConnectionStore: root.networkConnectionStore
isCommunityOwnershipTransfer: footer.isHoldingSelected && footer.isOwnerCommunityCollectible
communityName: {

View File

@ -25,6 +25,8 @@ Rectangle {
property var networkConnectionStore
required property TransactionStore transactionStore
property bool swapEnabled
// Community-token related properties:
required property bool isCommunityOwnershipTransfer
property string communityName: ""
@ -76,7 +78,7 @@ Rectangle {
readonly property bool buyActionAvailable: !isCollectibleViewed
readonly property bool swapActionAvailable: Global.featureFlags.swapEnabled
readonly property bool swapActionAvailable: root.swapEnabled
&& !walletStore.overview.isWatchOnlyAccount
&& walletStore.overview.canSend
&& !d.isCollectibleViewed

View File

@ -1,5 +1,6 @@
import QtQuick 2.13
import QtQuick.Layouts 1.13
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQml 2.15
import StatusQ 0.1
@ -25,6 +26,8 @@ Item {
property var store
property var walletStore
property bool dappsEnabled
property alias headerButton: headerButton
property alias networkFilter: networkFilter
@ -134,7 +137,7 @@ Item {
spacing: 8
visible: !root.walletStore.showSavedAddresses
&& Global.featureFlags.dappsEnabled
&& root.dappsEnabled
&& Global.walletConnectService.isServiceAvailableForAddressSelection
enabled: !!Global.walletConnectService

View File

@ -14,6 +14,9 @@ FocusScope {
property var communitiesStore
property var networkConnectionStore
property bool dappsEnabled
property bool swapEnabled
property var sendModal
property alias header: header
@ -33,6 +36,7 @@ FocusScope {
store: root.store
walletStore: RootStore
networkConnectionStore: root.networkConnectionStore
dappsEnabled: root.dappsEnabled
}
Item {

View File

@ -219,7 +219,7 @@ RightTabBaseView {
!RootStore.overview.isWatchOnlyAccount && RootStore.overview.canSend
communitySendEnabled: RootStore.tokensStore.showCommunityAssetsInSend
swapEnabled: !RootStore.overview.isWatchOnlyAccount
swapVisible: Global.featureFlags.swapEnabled
swapVisible: root.swapEnabled
onSendRequested: {
const modal = root.sendModal

View File

@ -0,0 +1,7 @@
import QtQml 2.15
QtObject {
property bool connectorEnabled
property bool dappsEnabled
property bool swapEnabled
}

View File

@ -1 +1,2 @@
RootStore 1.0 RootStore.qml
FeatureFlagsStore 1.0 FeatureFlagsStore.qml

View File

@ -79,6 +79,14 @@ Item {
tokensStore: appMain.tokensStore
currencyStore: appMain.currencyStore
}
readonly property FeatureFlagsStore featureFlagsStore: FeatureFlagsStore {
readonly property var featureFlags: typeof featureFlagsRootContextProperty !== undefined ? featureFlagsRootContextProperty : null
connectorEnabled: featureFlags ? featureFlags.connectorEnabled : false
dappsEnabled: featureFlags ? featureFlags.dappsEnabled : false
swapEnabled: featureFlags ? featureFlags.swapEnabled : false
}
required property bool isCentralizedMetricsEnabled
// set from main.qml
@ -1379,6 +1387,8 @@ Item {
sendModalPopup: sendModal
networkConnectionStore: appMain.networkConnectionStore
appMainVisible: appMain.visible
dappsEnabled: featureFlagsStore.dappsEnabled
swapEnabled: featureFlagsStore.swapEnabled
}
onLoaded: {
item.resetView()
@ -2137,7 +2147,7 @@ Item {
Loader {
id: dappsConnectorSDKLoader
active: Global.featureFlags.connectorEnabled
active: featureFlagsStore.connectorEnabled
sourceComponent: dappsConnectorSDK
}
@ -2145,7 +2155,7 @@ Item {
id: walletConnectServiceLoader
// It seems some of the functionality of the dapp connector depends on the WalletConnectService
active: (Global.featureFlags.dappsEnabled || Global.featureFlags.connectorEnabled) && appMain.visible
active: (featureFlagsStore.dappsEnabled || featureFlagsStore.connectorEnabled) && appMain.visible
sourceComponent: WalletConnectService {
id: walletConnectService

View File

@ -17,9 +17,6 @@ QtObject {
// use the generic var as type to break the cyclic dependency
property var walletConnectService: null
// avoid lookup of context property in QML
readonly property var featureFlags: featureFlagsRootContextProperty
signal openPinnedMessagesPopupRequested(var store, var messageStore, var pinnedMessagesModel, string messageToPin, string chatId)
signal openCommunityProfilePopupRequested(var store, var community, var chatCommunitySectionModule)