Merge pull request #4773 from mempool/mononaut/simplify-recent-txs

Simplify recent transactions observable
This commit is contained in:
wiz 2024-03-16 17:27:07 +09:00 committed by GitHub
commit d5e591c4af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 14 deletions

View file

@ -189,17 +189,7 @@ export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit {
})
);
this.transactions$ = this.stateService.transactions$
.pipe(
scan((acc, tx) => {
if (acc.find((t) => t.txid == tx.txid)) {
return acc;
}
acc.unshift(tx);
acc = acc.slice(0, 6);
return acc;
}, []),
);
this.transactions$ = this.stateService.transactions$;
this.blocks$ = this.stateService.blocks$
.pipe(

View file

@ -103,7 +103,7 @@ export class StateService {
lightningChanged$ = new ReplaySubject<boolean>(1);
blocksSubject$ = new BehaviorSubject<BlockExtended[]>([]);
blocks$: Observable<BlockExtended[]>;
transactions$ = new ReplaySubject<TransactionStripped>(6);
transactions$ = new BehaviorSubject<TransactionStripped[]>(null);
conversions$ = new ReplaySubject<any>(1);
bsqPrice$ = new ReplaySubject<number>(1);
mempoolInfo$ = new ReplaySubject<MempoolInfo>(1);
@ -219,7 +219,7 @@ export class StateService {
}
this.networkChanged$.subscribe((network) => {
this.transactions$ = new ReplaySubject<TransactionStripped>(6);
this.transactions$ = new BehaviorSubject<TransactionStripped[]>(null);
this.blocksSubject$.next([]);
});

View file

@ -343,7 +343,7 @@ export class WebsocketService {
}
if (response.transactions) {
response.transactions.forEach((tx) => this.stateService.transactions$.next(tx));
this.stateService.transactions$.next(response.transactions.slice(0, 6));
}
if (response['bsq-price']) {