Skip to content

Commit

Permalink
Merge pull request #97 from NazarUsov/mainnet/issues
Browse files Browse the repository at this point in the history
Fix update price | Mainnet
  • Loading branch information
cryptozoidberg authored Dec 1, 2023
2 parents 50e0771 + 3c6c2d9 commit 5456d86
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion html_source/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build --watch": "ng build --output-path \"/Applications/Zano.app/Contents/MacOS/html\" --watch",
"build --watch": "ng build --output-path \"/work/nazar/Zano/html/\" --watch",
"build --html": "node update-build-time.js && ng build --output-path \"../html/\"",
"test": "ng test",
"lint": "ng lint",
Expand Down
36 changes: 16 additions & 20 deletions html_source/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { BigNumber } from 'bignumber.js';
import { ModalService } from './_helpers/services/modal.service';
import { Store } from 'store';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import {shareReplay, switchMap, take, takeUntil} from 'rxjs/operators';
import { paths, pathsChildrenAuth } from './paths';

@Component({
Expand Down Expand Up @@ -610,11 +610,12 @@ export class AppComponent implements OnInit, OnDestroy {
});

this.variablesService.disable_price_fetch$.pipe(takeUntil(this._destroy$)).subscribe((disable_price_fetch) => {
const updateTime = 10 * 60 * 1000;
if (!disable_price_fetch) {
this.getMoneyEquivalent();
this.intervalUpdatePriceState = setInterval(() => {
this.getMoneyEquivalent();
}, 30000);
}, updateTime);
} else {
if (this.intervalUpdatePriceState) {
clearInterval(this.intervalUpdatePriceState);
Expand All @@ -624,25 +625,20 @@ export class AppComponent implements OnInit, OnDestroy {
}

getMoneyEquivalent() {
this.http.get('https://api.coingecko.com/api/v3/ping').subscribe(
() => {
this.http.get('https://api.coingecko.com/api/v3/simple/price?ids=zano&vs_currencies=usd&include_24hr_change=true').subscribe(
data => {
this.variablesService.moneyEquivalent = data['zano']['usd'];
this.variablesService.moneyEquivalentPercent = data['zano']['usd_24h_change'];
},
error => {
console.warn('api.coingecko.com price error: ', error);
}
);
const ping$ = this.http.get('https://api.coingecko.com/api/v3/ping').pipe(shareReplay(1));

ping$.pipe(
switchMap(() => this.http.get('https://api.coingecko.com/api/v3/simple/price?ids=zano&vs_currencies=usd&include_24hr_change=true')),
take(1)
).subscribe({
next: data => {
this.variablesService.moneyEquivalent = data['zano']['usd'];
this.variablesService.moneyEquivalentPercent = data['zano']['usd_24h_change'];
},
error => {
console.warn('api.coingecko.com error: ', error);
setTimeout(() => {
this.getMoneyEquivalent();
}, 30000);
}
);
error: error => {
console.warn('api.coingecko.com price error: ', error);
},
});
}

getAliases() {
Expand Down

0 comments on commit 5456d86

Please sign in to comment.