mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-20 10:38:47 +00:00
fix(@desktop/sync): settings/currency sync&backup handling
Part of #10389 issue.
This commit is contained in:
parent
4c29343a4a
commit
1e406269df
@ -71,9 +71,6 @@ method load*(self: Module) =
|
|||||||
self.events.on(SIGNAL_WALLET_ACCOUNT_DELETED) do(e:Args):
|
self.events.on(SIGNAL_WALLET_ACCOUNT_DELETED) do(e:Args):
|
||||||
self.refreshWalletAccounts()
|
self.refreshWalletAccounts()
|
||||||
|
|
||||||
self.events.on(SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED) do(e:Args):
|
|
||||||
self.refreshWalletAccounts()
|
|
||||||
|
|
||||||
self.events.on(SIGNAL_WALLET_ACCOUNT_UPDATED) do(e:Args):
|
self.events.on(SIGNAL_WALLET_ACCOUNT_UPDATED) do(e:Args):
|
||||||
self.refreshWalletAccounts()
|
self.refreshWalletAccounts()
|
||||||
|
|
||||||
|
@ -27,6 +27,9 @@ method toggleWatchOnlyAccounts*(self: AccessInterface) {.base.} =
|
|||||||
method updateCurrency*(self: AccessInterface, currency: string) {.base.} =
|
method updateCurrency*(self: AccessInterface, currency: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method getCurrentCurrency*(self: AccessInterface): string {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method setTotalCurrencyBalance*(self: AccessInterface) {.base.} =
|
method setTotalCurrencyBalance*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
@ -124,6 +124,9 @@ method delete*(self: Module) =
|
|||||||
method updateCurrency*(self: Module, currency: string) =
|
method updateCurrency*(self: Module, currency: string) =
|
||||||
self.controller.updateCurrency(currency)
|
self.controller.updateCurrency(currency)
|
||||||
|
|
||||||
|
method getCurrentCurrency*(self: Module): string =
|
||||||
|
self.controller.getCurrency()
|
||||||
|
|
||||||
method setTotalCurrencyBalance*(self: Module) =
|
method setTotalCurrencyBalance*(self: Module) =
|
||||||
self.view.setTotalCurrencyBalance(self.controller.getCurrencyBalance(self.filter.addresses))
|
self.view.setTotalCurrencyBalance(self.controller.getCurrencyBalance(self.filter.addresses))
|
||||||
|
|
||||||
@ -166,10 +169,6 @@ method load*(self: Module) =
|
|||||||
self.setTotalCurrencyBalance()
|
self.setTotalCurrencyBalance()
|
||||||
self.filter.removeAddress(args.address)
|
self.filter.removeAddress(args.address)
|
||||||
self.notifyFilterChanged()
|
self.notifyFilterChanged()
|
||||||
self.events.on(SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED) do(e:Args):
|
|
||||||
self.view.setCurrentCurrency(self.controller.getCurrency())
|
|
||||||
self.setTotalCurrencyBalance()
|
|
||||||
self.notifyFilterChanged()
|
|
||||||
self.events.on(SIGNAL_WALLET_ACCOUNT_NETWORK_ENABLED_UPDATED) do(e:Args):
|
self.events.on(SIGNAL_WALLET_ACCOUNT_NETWORK_ENABLED_UPDATED) do(e:Args):
|
||||||
self.filter.updateNetworks()
|
self.filter.updateNetworks()
|
||||||
self.setTotalCurrencyBalance()
|
self.setTotalCurrencyBalance()
|
||||||
@ -228,10 +227,9 @@ proc checkIfModuleDidLoad(self: Module) =
|
|||||||
if(not self.networksModule.isLoaded()):
|
if(not self.networksModule.isLoaded()):
|
||||||
return
|
return
|
||||||
|
|
||||||
let currency = self.controller.getCurrency()
|
|
||||||
let signingPhrase = self.controller.getSigningPhrase()
|
let signingPhrase = self.controller.getSigningPhrase()
|
||||||
let mnemonicBackedUp = self.controller.isMnemonicBackedUp()
|
let mnemonicBackedUp = self.controller.isMnemonicBackedUp()
|
||||||
self.view.setData(currency, signingPhrase, mnemonicBackedUp)
|
self.view.setData(signingPhrase, mnemonicBackedUp)
|
||||||
self.setTotalCurrencyBalance()
|
self.setTotalCurrencyBalance()
|
||||||
self.filter.load()
|
self.filter.load()
|
||||||
self.notifyFilterChanged()
|
self.notifyFilterChanged()
|
||||||
|
@ -91,9 +91,6 @@ method load*(self: Module) =
|
|||||||
self.events.on(SIGNAL_WALLET_ACCOUNT_DELETED) do(e:Args):
|
self.events.on(SIGNAL_WALLET_ACCOUNT_DELETED) do(e:Args):
|
||||||
self.refreshWalletAccounts()
|
self.refreshWalletAccounts()
|
||||||
|
|
||||||
self.events.on(SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED) do(e:Args):
|
|
||||||
self.refreshWalletAccounts()
|
|
||||||
|
|
||||||
self.events.on(SIGNAL_WALLET_ACCOUNT_UPDATED) do(e:Args):
|
self.events.on(SIGNAL_WALLET_ACCOUNT_UPDATED) do(e:Args):
|
||||||
self.refreshWalletAccounts()
|
self.refreshWalletAccounts()
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ QtObject:
|
|||||||
type
|
type
|
||||||
View* = ref object of QObject
|
View* = ref object of QObject
|
||||||
delegate: io_interface.AccessInterface
|
delegate: io_interface.AccessInterface
|
||||||
currentCurrency: string
|
|
||||||
totalCurrencyBalance: CurrencyAmount
|
totalCurrencyBalance: CurrencyAmount
|
||||||
signingPhrase: string
|
signingPhrase: string
|
||||||
isMnemonicBackedUp: bool
|
isMnemonicBackedUp: bool
|
||||||
@ -33,19 +32,12 @@ QtObject:
|
|||||||
|
|
||||||
proc showToastAccountAdded*(self: View, name: string) {.signal.}
|
proc showToastAccountAdded*(self: View, name: string) {.signal.}
|
||||||
|
|
||||||
proc currentCurrencyChanged*(self: View) {.signal.}
|
|
||||||
|
|
||||||
proc updateCurrency*(self: View, currency: string) {.slot.} =
|
proc updateCurrency*(self: View, currency: string) {.slot.} =
|
||||||
self.delegate.updateCurrency(currency)
|
self.delegate.updateCurrency(currency)
|
||||||
self.currentCurrency = currency
|
proc getCurrentCurrency(self: View): string {.slot.} =
|
||||||
self.currentCurrencyChanged()
|
return self.delegate.getCurrentCurrency()
|
||||||
|
QtProperty[string] currentCurrency:
|
||||||
proc getCurrentCurrency(self: View): QVariant {.slot.} =
|
|
||||||
return newQVariant(self.currentCurrency)
|
|
||||||
|
|
||||||
QtProperty[QVariant] currentCurrency:
|
|
||||||
read = getCurrentCurrency
|
read = getCurrentCurrency
|
||||||
notify = currentCurrencyChanged
|
|
||||||
|
|
||||||
proc totalCurrencyBalanceChanged*(self: View) {.signal.}
|
proc totalCurrencyBalanceChanged*(self: View) {.signal.}
|
||||||
|
|
||||||
@ -81,10 +73,6 @@ QtObject:
|
|||||||
self.totalCurrencyBalance = totalCurrencyBalance
|
self.totalCurrencyBalance = totalCurrencyBalance
|
||||||
self.totalCurrencyBalanceChanged()
|
self.totalCurrencyBalanceChanged()
|
||||||
|
|
||||||
proc setCurrentCurrency*(self: View, currency: string) =
|
|
||||||
self.currentCurrency = currency
|
|
||||||
self.currentCurrencyChanged()
|
|
||||||
|
|
||||||
# Returning a QVariant from a slot with parameters other than "self" won't compile
|
# Returning a QVariant from a slot with parameters other than "self" won't compile
|
||||||
# proc getCurrencyAmount*(self: View, amount: float, symbol: string): QVariant {.slot.} =
|
# proc getCurrencyAmount*(self: View, amount: float, symbol: string): QVariant {.slot.} =
|
||||||
# return newQVariant(self.delegate.getCurrencyAmount(amount, symbol))
|
# return newQVariant(self.delegate.getCurrencyAmount(amount, symbol))
|
||||||
@ -100,11 +88,9 @@ QtObject:
|
|||||||
self.tmpSymbol = "ERROR"
|
self.tmpSymbol = "ERROR"
|
||||||
return newQVariant(currencyAmount)
|
return newQVariant(currencyAmount)
|
||||||
|
|
||||||
proc setData*(self: View, currency, signingPhrase: string, mnemonicBackedUp: bool) =
|
proc setData*(self: View, signingPhrase: string, mnemonicBackedUp: bool) =
|
||||||
self.currentCurrency = currency
|
|
||||||
self.signingPhrase = signingPhrase
|
self.signingPhrase = signingPhrase
|
||||||
self.isMnemonicBackedUp = mnemonicBackedUp
|
self.isMnemonicBackedUp = mnemonicBackedUp
|
||||||
self.currentCurrencyChanged()
|
|
||||||
|
|
||||||
proc runAddAccountPopup*(self: View, addingWatchOnlyAccount: bool) {.slot.} =
|
proc runAddAccountPopup*(self: View, addingWatchOnlyAccount: bool) {.slot.} =
|
||||||
self.delegate.runAddAccountPopup(addingWatchOnlyAccount)
|
self.delegate.runAddAccountPopup(addingWatchOnlyAccount)
|
||||||
|
@ -20,20 +20,21 @@ const DEFAULT_CURRENCY* = "USD"
|
|||||||
const DEFAULT_TELEMETRY_SERVER_URL* = "https://telemetry.status.im"
|
const DEFAULT_TELEMETRY_SERVER_URL* = "https://telemetry.status.im"
|
||||||
const DEFAULT_FLEET* = $Fleet.StatusProd
|
const DEFAULT_FLEET* = $Fleet.StatusProd
|
||||||
|
|
||||||
|
# Signals:
|
||||||
|
const SIGNAL_CURRENCY_UPDATED* = "currencyUpdated"
|
||||||
const SIGNAL_CURRENT_USER_STATUS_UPDATED* = "currentUserStatusUpdated"
|
const SIGNAL_CURRENT_USER_STATUS_UPDATED* = "currentUserStatusUpdated"
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
topics = "settings-service"
|
topics = "settings-service"
|
||||||
|
|
||||||
type
|
type
|
||||||
|
SettingsTextValueArgs* = ref object of Args
|
||||||
|
value*: string
|
||||||
|
|
||||||
CurrentUserStatusArgs* = ref object of Args
|
CurrentUserStatusArgs* = ref object of Args
|
||||||
statusType*: StatusType
|
statusType*: StatusType
|
||||||
text*: string
|
text*: string
|
||||||
|
|
||||||
type
|
|
||||||
SettingProfilePictureArgs* = ref object of Args
|
|
||||||
value*: int
|
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type Service* = ref object of QObject
|
type Service* = ref object of QObject
|
||||||
events: EventEmitter
|
events: EventEmitter
|
||||||
@ -88,6 +89,7 @@ QtObject:
|
|||||||
for settingsField in receivedData.settings:
|
for settingsField in receivedData.settings:
|
||||||
if settingsField.name == KEY_CURRENCY:
|
if settingsField.name == KEY_CURRENCY:
|
||||||
self.settings.currency = settingsField.value
|
self.settings.currency = settingsField.value
|
||||||
|
self.events.emit(SIGNAL_CURRENCY_UPDATED, SettingsTextValueArgs(value: settingsField.value))
|
||||||
|
|
||||||
self.initialized = true
|
self.initialized = true
|
||||||
|
|
||||||
@ -131,6 +133,7 @@ QtObject:
|
|||||||
proc saveCurrency*(self: Service, value: string): bool =
|
proc saveCurrency*(self: Service, value: string): bool =
|
||||||
if(self.saveSetting(KEY_CURRENCY, value)):
|
if(self.saveSetting(KEY_CURRENCY, value)):
|
||||||
self.settings.currency = value.toLowerAscii()
|
self.settings.currency = value.toLowerAscii()
|
||||||
|
self.events.emit(SIGNAL_CURRENCY_UPDATED, SettingsTextValueArgs(value: self.settings.currency))
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ logScope:
|
|||||||
|
|
||||||
const SIGNAL_WALLET_ACCOUNT_SAVED* = "walletAccount/accountSaved"
|
const SIGNAL_WALLET_ACCOUNT_SAVED* = "walletAccount/accountSaved"
|
||||||
const SIGNAL_WALLET_ACCOUNT_DELETED* = "walletAccount/accountDeleted"
|
const SIGNAL_WALLET_ACCOUNT_DELETED* = "walletAccount/accountDeleted"
|
||||||
const SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED* = "walletAccount/currencyUpdated"
|
|
||||||
const SIGNAL_WALLET_ACCOUNT_UPDATED* = "walletAccount/walletAccountUpdated"
|
const SIGNAL_WALLET_ACCOUNT_UPDATED* = "walletAccount/walletAccountUpdated"
|
||||||
const SIGNAL_WALLET_ACCOUNT_NETWORK_ENABLED_UPDATED* = "walletAccount/networkEnabledUpdated"
|
const SIGNAL_WALLET_ACCOUNT_NETWORK_ENABLED_UPDATED* = "walletAccount/networkEnabledUpdated"
|
||||||
const SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT* = "walletAccount/tokensRebuilt"
|
const SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT* = "walletAccount/tokensRebuilt"
|
||||||
@ -333,11 +332,6 @@ QtObject:
|
|||||||
|
|
||||||
self.events.on(SignalType.Message.event) do(e: Args):
|
self.events.on(SignalType.Message.event) do(e: Args):
|
||||||
var receivedData = MessageSignal(e)
|
var receivedData = MessageSignal(e)
|
||||||
if receivedData.settings.len > 0:
|
|
||||||
for settingsField in receivedData.settings:
|
|
||||||
if settingsField.name == KEY_CURRENCY:
|
|
||||||
self.events.emit(SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED, CurrencyUpdated())
|
|
||||||
|
|
||||||
if receivedData.walletAccounts.len > 0:
|
if receivedData.walletAccounts.len > 0:
|
||||||
for acc in receivedData.walletAccounts:
|
for acc in receivedData.walletAccounts:
|
||||||
self.handleWalletAccount(acc)
|
self.handleWalletAccount(acc)
|
||||||
@ -351,6 +345,9 @@ QtObject:
|
|||||||
self.buildAllTokens(self.getAddresses(), store = true)
|
self.buildAllTokens(self.getAddresses(), store = true)
|
||||||
self.checkRecentHistory()
|
self.checkRecentHistory()
|
||||||
|
|
||||||
|
self.events.on(SIGNAL_CURRENCY_UPDATED) do(e:Args):
|
||||||
|
self.buildAllTokens(self.getAddresses(), store = true)
|
||||||
|
|
||||||
proc reloadAccountTokens*(self: Service) =
|
proc reloadAccountTokens*(self: Service) =
|
||||||
self.buildAllTokens(self.getAddresses(), store = true)
|
self.buildAllTokens(self.getAddresses(), store = true)
|
||||||
self.checkRecentHistory()
|
self.checkRecentHistory()
|
||||||
@ -523,8 +520,6 @@ QtObject:
|
|||||||
|
|
||||||
proc updateCurrency*(self: Service, newCurrency: string) =
|
proc updateCurrency*(self: Service, newCurrency: string) =
|
||||||
discard self.settingsService.saveCurrency(newCurrency)
|
discard self.settingsService.saveCurrency(newCurrency)
|
||||||
self.buildAllTokens(self.getAddresses(), store = true)
|
|
||||||
self.events.emit(SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED, CurrencyUpdated())
|
|
||||||
|
|
||||||
proc setNetworksState*(self: Service, chainIds: seq[int], enabled: bool) =
|
proc setNetworksState*(self: Service, chainIds: seq[int], enabled: bool) =
|
||||||
self.networkService.setNetworksState(chainIds, enabled)
|
self.networkService.setNetworksState(chainIds, enabled)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user