Bigfix: Don't chime when switching networks.

fixes #84
This commit is contained in:
softsimon
2020-06-11 00:11:15 +07:00
parent e0a451eb05
commit 32c3f0c182
3 changed files with 5 additions and 7 deletions

View File

@@ -4,7 +4,6 @@ import { Block } from 'src/app/interfaces/electrs.interface';
import { StateService } from 'src/app/services/state.service';
import { Router } from '@angular/router';
import { AudioService } from 'src/app/services/audio.service';
import { KEEP_BLOCKS_AMOUNT } from 'src/app/app.constants';
@Component({
selector: 'app-blockchain-blocks',
@@ -40,15 +39,14 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy {
this.stateService.networkChanged$.subscribe((network) => this.network = network);
this.blocksSubscription = this.stateService.blocks$
.subscribe(([block, txConfirmed]) => {
const currentBlocksAmount = this.blocks.length;
.subscribe(([block, txConfirmed, refilling]) => {
if (this.blocks.some((b) => b.height === block.height)) {
return;
}
this.blocks.unshift(block);
this.blocks = this.blocks.slice(0, 8);
if (currentBlocksAmount === KEEP_BLOCKS_AMOUNT) {
if (!refilling) {
setTimeout(() => this.audioService.playSound('bright-harmony'));
block.stage = block.matchRate >= 80 ? 1 : 2;
}