fix: handle sync currency settings
This updates the desktop client with a newly emitted currency settings that might originate from synchronization Partially addresses #5201
This commit is contained in:
parent
355fe7b77d
commit
95a1945bff
|
@ -102,6 +102,7 @@ method load*(self: Module) =
|
||||||
self.switchAccount(0)
|
self.switchAccount(0)
|
||||||
self.setTotalCurrencyBalance()
|
self.setTotalCurrencyBalance()
|
||||||
self.events.on(SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED) do(e:Args):
|
self.events.on(SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED) do(e:Args):
|
||||||
|
self.view.setCurrentCurrency(self.controller.getCurrency())
|
||||||
self.setTotalCurrencyBalance()
|
self.setTotalCurrencyBalance()
|
||||||
self.events.on(SIGNAL_WALLET_ACCOUNT_TOKEN_VISIBILITY_UPDATED) do(e:Args):
|
self.events.on(SIGNAL_WALLET_ACCOUNT_TOKEN_VISIBILITY_UPDATED) do(e:Args):
|
||||||
self.setTotalCurrencyBalance()
|
self.setTotalCurrencyBalance()
|
||||||
|
|
|
@ -70,6 +70,10 @@ QtObject:
|
||||||
self.totalCurrencyBalance = totalCurrencyBalance
|
self.totalCurrencyBalance = totalCurrencyBalance
|
||||||
self.totalCurrencyBalanceChanged()
|
self.totalCurrencyBalanceChanged()
|
||||||
|
|
||||||
|
proc setCurrentCurrency*(self: View, currency: string) =
|
||||||
|
self.currentCurrency = currency
|
||||||
|
self.currentCurrencyChanged()
|
||||||
|
|
||||||
proc setData*(self: View, currency, signingPhrase: string, mnemonicBackedUp: bool) =
|
proc setData*(self: View, currency, signingPhrase: string, mnemonicBackedUp: bool) =
|
||||||
self.currentCurrency = currency
|
self.currentCurrency = currency
|
||||||
self.signingPhrase = signingPhrase
|
self.signingPhrase = signingPhrase
|
||||||
|
|
|
@ -74,6 +74,9 @@ QtObject:
|
||||||
self.settings.profilePicturesVisibility = settingsfield.value.parseInt
|
self.settings.profilePicturesVisibility = settingsfield.value.parseInt
|
||||||
self.events.emit(SIGNAL_SETTING_PROFILE_PICTURES_VISIBILITY_CHANGED, SettingProfilePictureArgs(value: self.settings.profilePicturesVisibility))
|
self.events.emit(SIGNAL_SETTING_PROFILE_PICTURES_VISIBILITY_CHANGED, SettingProfilePictureArgs(value: self.settings.profilePicturesVisibility))
|
||||||
|
|
||||||
|
if settingsField.name == KEY_CURRENCY:
|
||||||
|
self.settings.currency = settingsField.value
|
||||||
|
|
||||||
proc saveSetting(self: Service, attribute: string, value: string | JsonNode | bool | int): bool =
|
proc saveSetting(self: Service, attribute: string, value: string | JsonNode | bool | int): bool =
|
||||||
try:
|
try:
|
||||||
let response = status_settings.saveSettings(attribute, value)
|
let response = status_settings.saveSettings(attribute, value)
|
||||||
|
|
|
@ -12,6 +12,7 @@ import dto
|
||||||
import derived_address
|
import derived_address
|
||||||
|
|
||||||
import ../../../app/core/eventemitter
|
import ../../../app/core/eventemitter
|
||||||
|
import ../../../app/core/signals/types
|
||||||
import ../../../app/core/tasks/[qt, threadpool]
|
import ../../../app/core/tasks/[qt, threadpool]
|
||||||
import ../../../backend/accounts as status_go_accounts
|
import ../../../backend/accounts as status_go_accounts
|
||||||
import ../../../backend/backend as backend
|
import ../../../backend/backend as backend
|
||||||
|
@ -160,6 +161,13 @@ QtObject:
|
||||||
error "error: ", errDesription
|
error "error: ", errDesription
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.events.on(SignalType.Message.event) do(e: Args):
|
||||||
|
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())
|
||||||
|
|
||||||
proc getAccountByAddress*(self: Service, address: string): WalletAccountDto =
|
proc getAccountByAddress*(self: Service, address: string): WalletAccountDto =
|
||||||
if not self.walletAccounts.hasKey(address):
|
if not self.walletAccounts.hasKey(address):
|
||||||
return
|
return
|
||||||
|
|
|
@ -843,8 +843,7 @@ QtObject {
|
||||||
var isSelected = false
|
var isSelected = false
|
||||||
for(var i = 0; i < currenciesModel.count; i++) {
|
for(var i = 0; i < currenciesModel.count; i++) {
|
||||||
if(root.currentCurrency === root.currenciesModel.get(i).key) {
|
if(root.currentCurrency === root.currenciesModel.get(i).key) {
|
||||||
isSelected = true
|
root.currenciesModel.get(i).selected = isSelected = true
|
||||||
root.currenciesModel.get(i).selected = true
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
root.currenciesModel.get(i).selected = false
|
root.currenciesModel.get(i).selected = false
|
||||||
|
|
Loading…
Reference in New Issue