feat(@desktop/wallet): remove isWalletEnabled from local settings and

use ENABLE_WALLET env instead
This commit is contained in:
Ivan Belyakov 2023-03-15 16:35:03 +03:00 committed by IvanBelyakoff
parent ee3d92c12b
commit 02ebc8744c
12 changed files with 29 additions and 51 deletions

View File

@ -6,8 +6,6 @@ import ../../constants
const LSS_KEY_CHAT_SPLIT_VIEW* = "chatSplitView"
const LSS_KEY_WALLET_SPLIT_VIEW* = "walletSplitView"
const LSS_KEY_PROFILE_SPLIT_VIEW* = "profileSplitView"
const LSS_KEY_IS_WALLET_ENABLED* = "isExperimentalWalletEnabled"
const DEFAULT_IS_WALLET_ENABLED = true
const LSS_KEY_IS_COMMUNITY_PERMISSIONS_ENABLED* = "isExperimentalCommunityPermissionsEnabled"
const DEFAULT_IS_COMMUNITY_PERMISSIONS_ENABLED = false
const LSS_KEY_IS_COMMUNITY_TOKENS_ENABLED* = "isExperimentalCommunityTokensEnabled"
@ -253,18 +251,6 @@ QtObject:
write = setIsCommunityTokensEnabled
notify = isCommunityTokensEnabledChanged
proc isWalletEnabledChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getIsWalletEnabled*(self: LocalAccountSensitiveSettings): bool {.slot.} =
getSettingsProp[bool](self, LSS_KEY_IS_WALLET_ENABLED, newQVariant(DEFAULT_IS_WALLET_ENABLED))
proc setIsWalletEnabled*(self: LocalAccountSensitiveSettings, value: bool) {.slot.} =
setSettingsProp(self, LSS_KEY_IS_WALLET_ENABLED, newQVariant(value)):
self.isWalletEnabledChanged()
QtProperty[bool] isWalletEnabled:
read = getIsWalletEnabled
write = setIsWalletEnabled
notify = isWalletEnabledChanged
proc nodeManagementEnabledChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getNodeManagementEnabled*(self: LocalAccountSensitiveSettings): bool {.slot.} =
getSettingsProp[bool](self, LSS_KEY_NODE_MANAGEMENT_ENABLED, newQVariant(DEFAULT_NODE_MANAGEMENT_ENABLED))
@ -788,7 +774,6 @@ QtObject:
of LSS_KEY_CHAT_SPLIT_VIEW: self.chatSplitViewChanged()
of LSS_KEY_WALLET_SPLIT_VIEW: self.walletSplitViewChanged()
of LSS_KEY_PROFILE_SPLIT_VIEW: self.profileSplitViewChanged()
of LSS_KEY_IS_WALLET_ENABLED: self.isWalletEnabledChanged()
of LSS_KEY_IS_COMMUNITY_PERMISSIONS_ENABLED: self.isCommunityPermissionsEnabledChanged()
of LSS_KEY_NODE_MANAGEMENT_ENABLED: self.nodeManagementEnabledChanged()
of LSS_KEY_IS_BROWSER_ENABLED: self.isBrowserEnabledChanged()

View File

@ -8,6 +8,7 @@ import ../shared_modules/keycard_popup/module as keycard_shared_module
import ../../global/app_sections_config as conf
import ../../global/app_signals
import ../../global/global_singleton
import ../../../constants as main_constants
import chat_section/model as chat_model
import chat_section/item as chat_item
@ -414,7 +415,7 @@ method load*[T](
hasNotification = false,
notificationsCount = 0,
active = false,
enabled = singletonInstance.localAccountSensitiveSettings.getIsWalletEnabled(),
enabled = main_constants.WALLET_ENABLED,
)
self.view.model().addItem(walletSectionItem)
if(activeSectionId == walletSectionItem.id):
@ -710,11 +711,7 @@ proc setSectionAvailability[T](self: Module[T], sectionType: SectionType, availa
self.view.model().disableSection(sectionType)
method toggleSection*[T](self: Module[T], sectionType: SectionType) =
if (sectionType == SectionType.Wallet):
let enabled = singletonInstance.localAccountSensitiveSettings.getIsWalletEnabled()
self.setSectionAvailability(sectionType, not enabled)
singletonInstance.localAccountSensitiveSettings.setIsWalletEnabled(not enabled)
elif (sectionType == SectionType.Browser):
if (sectionType == SectionType.Browser):
let enabled = singletonInstance.localAccountSensitiveSettings.getIsBrowserEnabled()
self.setSectionAvailability(sectionType, not enabled)
singletonInstance.localAccountSensitiveSettings.setIsBrowserEnabled(not enabled)

View File

@ -312,6 +312,10 @@ QtObject:
if(it.sectionType == sectionType):
return it
proc getItemEnabledBySectionType*(self: SectionModel, sectionType: int): bool {.slot.} =
let item = self.getItemBySectionType((SectionType)sectionType)
return not item.isEmpty() and item.enabled()
proc setActiveSection*(self: SectionModel, id: string) =
for i in 0 ..< self.items.len:
if(self.items[i].active):

View File

@ -12,6 +12,7 @@ import ../../../app/global/global_singleton
import ../../../app/core/eventemitter
import ../../../app/core/tasks/[qt, threadpool]
import ../../common/cache
import ../../../constants as main_constants
import ./dto
export dto
@ -78,7 +79,7 @@ QtObject:
result.tokensToAddressesMap = initTable[string, TokenData]()
proc loadData*(self: Service) =
if(not singletonInstance.localAccountSensitiveSettings.getIsWalletEnabled()):
if(not main_constants.WALLET_ENABLED):
return
try:
@ -135,7 +136,6 @@ QtObject:
error "Tokens init error", errDesription = e.msg
proc init*(self: Service) =
signalConnect(singletonInstance.localAccountSensitiveSettings, "isWalletEnabledChanged()", self, "onIsWalletEnabledChanged()", 2)
self.loadData()
proc getTokenList*(self: Service): seq[TokenDto] =
@ -152,9 +152,6 @@ QtObject:
if self.hasContractAddressesForToken(symbol):
return self.tokensToAddressesMap[symbol].addresses
proc onIsWalletEnabledChanged*(self: Service) {.slot.} =
self.loadData()
proc findTokenBySymbol*(self: Service, network: NetworkDto, symbol: string): TokenDto =
try:
for token in self.tokens[network.chainId]:

View File

@ -24,6 +24,7 @@ import ./dto as transaction_dto
import ./cryptoRampDto
import ../eth/utils as eth_utils
import ../../common/conversion
import ../../../constants as main_constants
export transaction_dto
@ -129,8 +130,6 @@ QtObject:
result.allTxLoaded = initTable[string, bool]()
proc init*(self: Service) =
signalConnect(singletonInstance.localAccountSensitiveSettings, "isWalletEnabledChanged()", self, "onIsWalletEnabledChanged()", 2)
self.events.on(SignalType.Wallet.event) do(e:Args):
var data = WalletSignal(e)
case data.eventType:
@ -511,7 +510,7 @@ QtObject:
self.events.emit(SIGNAL_CRYPTO_SERVICES_READY, CryptoServicesArgs(data: cryptoServices))
proc fetchCryptoServices*(self: Service) =
if(not singletonInstance.localAccountSensitiveSettings.getIsWalletEnabled()):
if(not main_constants.WALLET_ENABLED):
return
let arg = GetCryptoServicesTaskArg(
@ -536,6 +535,3 @@ QtObject:
except Exception as e:
error "Error getting latest block number", message = e.msg
return ""
proc onIsWalletEnabledChanged*(self: Service) {.slot.} =
self.fetchCryptoServices()

View File

@ -18,6 +18,7 @@ import ../../../backend/accounts as status_go_accounts
import ../../../backend/backend as backend
import ../../../backend/eth as status_go_eth
import ../../../backend/transactions as status_go_transactions
import ../../../constants as main_constants
export dto, derived_address, key_pair_dto
@ -221,8 +222,6 @@ QtObject:
result = toSeq(self.walletAccounts.keys())
proc init*(self: Service) =
signalConnect(singletonInstance.localAccountSensitiveSettings, "isWalletEnabledChanged()", self, "onIsWalletEnabledChanged()", 2)
try:
let accounts = self.fetchAccounts()
for account in accounts:
@ -270,13 +269,13 @@ QtObject:
return i
proc startWallet(self: Service) =
if(not singletonInstance.localAccountSensitiveSettings.getIsWalletEnabled()):
if(not main_constants.WALLET_ENABLED):
return
discard backend.startWallet()
proc checkConnected(self: Service) =
if(not singletonInstance.localAccountSensitiveSettings.getIsWalletEnabled()):
if(not main_constants.WALLET_ENABLED):
return
try:
@ -289,7 +288,7 @@ QtObject:
proc checkRecentHistory*(self: Service) =
if(not singletonInstance.localAccountSensitiveSettings.getIsWalletEnabled()):
if(not main_constants.WALLET_ENABLED):
return
try:
@ -581,7 +580,7 @@ QtObject:
error "error: ", procName="onAllTokensBuilt", errName = e.name, errDesription = e.msg
proc buildAllTokens(self: Service, accounts: seq[string], store: bool) =
if not singletonInstance.localAccountSensitiveSettings.getIsWalletEnabled() or
if not main_constants.WALLET_ENABLED or
accounts.len == 0:
return
@ -594,11 +593,6 @@ QtObject:
)
self.threadpool.start(arg)
proc onIsWalletEnabledChanged*(self: Service) {.slot.} =
self.buildAllTokens(self.getAddresses(), store = true)
self.checkRecentHistory()
self.startWallet()
proc getCurrentCurrencyIfEmpty(self: Service, currency = ""): string =
if currency != "":
return currency

View File

@ -3,6 +3,12 @@ import os, sequtils, strutils, strformat
import # vendor libs
confutils
const DEFAULT_WALLET_ENABLED = true
let WALLET_ENABLED* = if (existsEnv("ENABLE_WALLET")):
parseInt($getEnv("ENABLE_WALLET")) != 0
else:
DEFAULT_WALLET_ENABLED
## Added a constant here cause it's easier to check the app how it behaves
## on other platform if we just change the value here
const IS_MACOS* = defined(macosx)

View File

@ -68,7 +68,7 @@ QtObject {
}
property bool browserMenuItemEnabled: Global.appIsReady? localAccountSensitiveSettings.isBrowserEnabled : false
property bool walletMenuItemEnabled: Global.appIsReady? localAccountSensitiveSettings.isWalletEnabled : false
property bool walletMenuItemEnabled: profileStore.isWalletEnabled
property var communitiesModuleInst: Global.appIsReady? communitiesModule : null
property var communitiesList: !!communitiesModuleInst? communitiesModuleInst.model : null

View File

@ -25,6 +25,8 @@ QtObject {
readonly property var temporarySocialLinksJson: profileModule.temporarySocialLinksJson
readonly property bool socialLinksDirty: profileModule.socialLinksDirty
readonly property bool isWalletEnabled: Global.appIsReady? mainModule.sectionsModel.getItemEnabledBySectionType(Constants.appSection.wallet) : false
onUserDeclinedBackupBannerChanged: {
if (userDeclinedBackupBanner !== localAccountSensitiveSettings.userDeclinedBackupBanner) {
localAccountSensitiveSettings.userDeclinedBackupBanner = userDeclinedBackupBanner

View File

@ -180,7 +180,7 @@ ColumnLayout {
}
StatusTabButton {
enabled: localAccountSensitiveSettings.isWalletEnabled
enabled: root.profileStore.isWalletEnabled
width: enabled ? implicitWidth : 0
text: qsTr("Accounts")
onEnabledChanged: showcaseTabBar.validateCurrentIndex()

View File

@ -71,7 +71,7 @@ Item {
}
}
readonly property bool walletEnabled: localAccountSensitiveSettings.isWalletEnabled
readonly property bool walletEnabled: SharedStores.RootStore.isWalletEnabled
onWalletEnabledChanged: {
update()
}

View File

@ -17,7 +17,8 @@ QtObject {
property var appSettingsInst: Global.appIsReady && !!appSettings? appSettings : null
property var accountSensitiveSettings: Global.appIsReady && !!localAccountSensitiveSettings? localAccountSensitiveSettings : null
property real volume: !!appSettingsInst ? appSettingsInst.volume * 0.01 : 0.5
property bool isWalletEnabled: !!accountSensitiveSettings ? accountSensitiveSettings.isWalletEnabled : false
property bool isWalletEnabled: Global.appIsReady? mainModule.sectionsModel.getItemEnabledBySectionType(Constants.appSection.wallet) : false
property bool notificationSoundsEnabled: !!appSettingsInst ? appSettingsInst.notificationSoundsEnabled : true
property bool neverAskAboutUnfurlingAgain: !!accountSensitiveSettings ? accountSensitiveSettings.neverAskAboutUnfurlingAgain : false
property bool isGifWidgetEnabled: !!accountSensitiveSettings ? accountSensitiveSettings.isGifWidgetEnabled : false
@ -91,10 +92,6 @@ QtObject {
localAccountSensitiveSettings.neverAskAboutUnfurlingAgain = value;
}
function enableWallet() {
localAccountSensitiveSettings.isWalletEnabled = true;
}
function setIsTenorWarningAccepted(value) {
localAccountSensitiveSettings.isTenorWarningAccepted = value;
}