Bigfix: Don't chime when switching networks.

fixes #84
This commit is contained in:
softsimon 2020-06-11 00:11:15 +07:00
parent 36e46249b5
commit 43dac03ec0
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
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;
}

View File

@ -20,7 +20,7 @@ export class StateService {
latestBlockHeight = 0;
networkChanged$ = new ReplaySubject<string>(1);
blocks$ = new ReplaySubject<[Block, boolean]>(KEEP_BLOCKS_AMOUNT);
blocks$ = new ReplaySubject<[Block, boolean, boolean]>(KEEP_BLOCKS_AMOUNT);
conversions$ = new ReplaySubject<any>(1);
mempoolStats$ = new ReplaySubject<MemPoolState>(1);
mempoolBlocks$ = new ReplaySubject<MempoolBlock[]>(1);

View File

@ -64,7 +64,7 @@ export class WebsocketService {
blocks.forEach((block: Block) => {
if (block.height > this.stateService.latestBlockHeight) {
this.stateService.latestBlockHeight = block.height;
this.stateService.blocks$.next([block, false]);
this.stateService.blocks$.next([block, false, true]);
}
});
}
@ -76,7 +76,7 @@ export class WebsocketService {
if (response.block) {
if (response.block.height > this.stateService.latestBlockHeight) {
this.stateService.latestBlockHeight = response.block.height;
this.stateService.blocks$.next([response.block, !!response.txConfirmed]);
this.stateService.blocks$.next([response.block, !!response.txConfirmed, false]);
}
if (response.txConfirmed) {