Skip to content

Commit

Permalink
fix fiat switching, fix validatorutils
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelsc committed Oct 19, 2023
1 parent f6d750c commit 7d58036
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
9 changes: 9 additions & 0 deletions src/app/services/unitconv.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ export class UnitconvService {
await this.init()
}

public async changeCurrency(value: string) {
this.pref.Cons = this.createCurrency(value, 'cons')
await this.updatePriceData()
}

public async getCurrentConsFiat() {
return this.createCurrency(this.getPref(await this.loadStored(STORAGE_KEY_CONS), this.getNetworkDefaultCurrency('cons')), 'cons').value
}

private async loadStored(key: string): Promise<StoredPref> {
const result = await this.storage.getObject(key)
if (!result) return null
Expand Down
2 changes: 1 addition & 1 deletion src/app/tab-preferences/tab-preferences.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<ion-select
label="Display Currency"
[value]="unit.getNetworkDefaultCurrency(unit.pref.Cons)"
[(ngModel)]="unit.pref.Cons.value"
[(ngModel)]="currentFiatCurrency"
(ionChange)="changeCurrency()"
interface="popover"
*ngIf="overrideDisplayCurrency == null">
Expand Down
8 changes: 6 additions & 2 deletions src/app/tab-preferences/tab-preferences.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class Tab3Page {
premiumLabel = ''

protected package = ''
protected currentFiatCurrency

constructor(
protected api: ApiService,
Expand All @@ -103,6 +104,9 @@ export class Tab3Page {
) {}

ngOnInit() {
this.unit.getCurrentConsFiat().then((result) => {
this.currentFiatCurrency = result
})
this.theme.isDarkThemed().then((result) => (this.darkMode = result))

this.theme.getThemeColor().then((result) => (this.themeColor = result))
Expand Down Expand Up @@ -230,13 +234,13 @@ export class Tab3Page {

overrideDisplayCurrency = null
private changeCurrencyLocked = false
changeCurrency() {
async changeCurrency() {
if (this.changeCurrencyLocked) return
this.changeCurrencyLocked = true

this.overrideDisplayCurrency = this.unit.pref

this.unit.updatePriceData()
await this.unit.changeCurrency(this.currentFiatCurrency)
this.unit.save()

setTimeout(() => {
Expand Down
8 changes: 4 additions & 4 deletions src/app/utils/ValidatorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,16 +371,16 @@ export class ValidatorUtils extends CacheModule {

const result = request.parse(response)[0]
if (!result) {
console.warn('error getDashboardDataValidators', response)
console.warn('error getDashboardDataValidators', response, result)
return []
}
if (result.currentEpoch && result.currentEpoch.length > 1) {
if (result.currentEpoch && result.currentEpoch.length > 0) {
this.currentEpoch = result.currentEpoch[0]
}
if (result.olderEpoch && result.olderEpoch.length > 1) {
if (result.olderEpoch && result.olderEpoch.length > 0) {
this.olderEpoch = result.olderEpoch[0]
}
if (result.rocketpool_network_stats && result.rocketpool_network_stats.length > 1) {
if (result.rocketpool_network_stats && result.rocketpool_network_stats.length > 0) {
this.rocketpoolStats = result.rocketpool_network_stats[0]
}
const validatorEffectivenessResponse = result.effectiveness
Expand Down

0 comments on commit 7d58036

Please sign in to comment.