Use asyncScheduler for all derives (#2043)
This commit is contained in:
@@ -6,9 +6,9 @@ import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { ProposalIndex, TreasuryProposal } from '@polkadot/types/interfaces';
|
||||
import { DerivedCollectiveProposals, DerivedTreasuryProposal, DerivedTreasuryProposals } from '../types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { createType, Option } from '@polkadot/types';
|
||||
import { Observable, asyncScheduler, combineLatest, of } from 'rxjs';
|
||||
import { map, observeOn, switchMap } from 'rxjs/operators';
|
||||
import { Option } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -55,7 +55,7 @@ function retrieveProposals (api: ApiInterfaceRx, proposalCount: ProposalIndex, a
|
||||
const isApproval = approvalIds.some((id): boolean => id.eqn(index));
|
||||
|
||||
if (!isApproval) {
|
||||
proposalIds.push(createType(api.registry, 'ProposalIndex', index));
|
||||
proposalIds.push(api.registry.createType('ProposalIndex', index));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ function retrieveProposals (api: ApiInterfaceRx, proposalCount: ProposalIndex, a
|
||||
api.query.treasury.proposals.multi<Option<TreasuryProposal>>(allIds),
|
||||
api.derive.council.proposals()
|
||||
]).pipe(
|
||||
observeOn(asyncScheduler),
|
||||
map(([allProposals, councilProposals]: [Option<TreasuryProposal>[], DerivedCollectiveProposals]): DerivedTreasuryProposals =>
|
||||
parseResult(api, { allIds, allProposals, approvalIds, councilProposals, proposalCount })
|
||||
)
|
||||
@@ -81,13 +82,14 @@ export function proposals (api: ApiInterfaceRx): () => Observable<DerivedTreasur
|
||||
api.query.treasury.proposalCount(),
|
||||
api.query.treasury.approvals()
|
||||
]).pipe(
|
||||
observeOn(asyncScheduler),
|
||||
switchMap(([proposalCount, approvalIds]: [ProposalIndex, ProposalIndex[]]) =>
|
||||
retrieveProposals(api, proposalCount, approvalIds)
|
||||
)
|
||||
)
|
||||
: of({
|
||||
approvals: [],
|
||||
proposalCount: createType(api.registry, 'ProposalIndex'),
|
||||
proposalCount: api.registry.createType('ProposalIndex'),
|
||||
proposals: []
|
||||
} as DerivedTreasuryProposals)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user