Clear dispatchQueue on bestNumber > enact (#5782)

This commit is contained in:
Jaco 2021-07-07 08:21:06 +03:00 committed by GitHub
parent 823d46d77c
commit ec6859d5e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ import type { DeriveDispatch } from '@polkadot/api-derive/types';
import React, { useRef } from 'react';
import { Table } from '@polkadot/react-components';
import { useApi, useCall } from '@polkadot/react-hooks';
import { useApi, useBestNumber, useCall } from '@polkadot/react-hooks';
import { useTranslation } from '../translate';
import DispatchEntry from './DispatchEntry';
@ -18,6 +18,7 @@ interface Props {
function DispatchQueue ({ className }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation();
const { api } = useApi();
const bestNumber = useBestNumber();
const queued = useCall<DeriveDispatch[]>(api.derive.democracy.dispatchQueue);
const headerRef = useRef([
@ -33,7 +34,7 @@ function DispatchQueue ({ className }: Props): React.ReactElement<Props> | null
empty={queued && t<string>('Nothing queued for execution')}
header={headerRef.current}
>
{queued?.map((entry): React.ReactNode => (
{bestNumber && queued?.filter(({ at }) => bestNumber.gte(at)).map((entry): React.ReactNode => (
<DispatchEntry
key={entry.index.toString()}
value={entry}