Use leaseOffset in start event calculation (#7048)
This commit is contained in:
parent
cf406781af
commit
d32a3c8870
@ -9,6 +9,7 @@ import styled from 'styled-components';
|
||||
import { Button } from '@polkadot/react-components';
|
||||
|
||||
import DayItem from './DayItem';
|
||||
import { useTranslation } from './translate';
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
@ -17,6 +18,7 @@ interface Props {
|
||||
}
|
||||
|
||||
function UpcomingEvents ({ className, scheduled, setView }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const sched = useMemo(
|
||||
() => scheduled.sort((a, b) => a.dateTime - b.dateTime),
|
||||
[scheduled]
|
||||
@ -36,7 +38,7 @@ function UpcomingEvents ({ className, scheduled, setView }: Props): React.ReactE
|
||||
icon='calendar'
|
||||
onClick={_setView}
|
||||
/>
|
||||
Upcoming Events
|
||||
{t<string>('Upcoming Events')}
|
||||
</div>
|
||||
</h1>
|
||||
<ul className='allEventsWrapper'>
|
||||
|
||||
@ -29,19 +29,20 @@ function newDate (blocks: BN, blockTime: number): DateExt {
|
||||
return { date, dateTime: date.getTime() };
|
||||
}
|
||||
|
||||
function createConstDurations (bestNumber: BlockNumber, blockTime: number, items: [EntryType, BlockNumber?, BN?][]): [EntryType, EntryInfo[]][] {
|
||||
return items.map(([type, duration, additional = BN_ZERO]): [EntryType, EntryInfo[]] => {
|
||||
function createConstDurations (bestNumber: BlockNumber, blockTime: number, items: [EntryType, BlockNumber?, BN?, BN?][]): [EntryType, EntryInfo[]][] {
|
||||
return items.map(([type, duration, additional = BN_ZERO, offset = BN_ZERO]): [EntryType, EntryInfo[]] => {
|
||||
if (!duration) {
|
||||
return [type, []];
|
||||
}
|
||||
|
||||
const blocks = duration.sub(bestNumber.mod(duration));
|
||||
const startNumber = bestNumber.sub(offset);
|
||||
const blocks = duration.sub(startNumber.mod(duration));
|
||||
|
||||
return [type, [{
|
||||
...newDate(blocks, blockTime),
|
||||
blockNumber: bestNumber.add(blocks),
|
||||
blockNumber: startNumber.add(blocks),
|
||||
blocks,
|
||||
info: bestNumber.div(duration).iadd(additional)
|
||||
info: startNumber.div(duration).iadd(additional)
|
||||
}]];
|
||||
});
|
||||
}
|
||||
@ -251,7 +252,7 @@ function useScheduledImpl (): EntryInfo[] {
|
||||
addFiltered(state, createConstDurations(bestNumber, blockTime, [
|
||||
['councilElection', (api.consts.elections || api.consts.phragmenElection || api.consts.electionsPhragmen)?.termDuration],
|
||||
['democracyLaunch', api.consts.democracy?.launchPeriod],
|
||||
['parachainLease', api.consts.slots?.leasePeriod as BlockNumber, BN_ONE],
|
||||
['parachainLease', api.consts.slots?.leasePeriod as BlockNumber, BN_ONE, api.consts.slots?.leaseOffset as BlockNumber],
|
||||
['societyChallenge', api.consts.society?.challengePeriod],
|
||||
['societyRotate', api.consts.society?.rotationPeriod],
|
||||
['treasurySpend', api.consts.treasury?.spendPeriod]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user