-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Join pool progress bar on performance fetch. (#2064)
- Loading branch information
Ross Bulat
authored
Apr 5, 2024
1 parent
69d716e
commit e5027ff
Showing
4 changed files
with
70 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
import BigNumber from 'bignumber.js'; | ||
import { usePoolPerformance } from 'contexts/Pools/PoolPerformance'; | ||
|
||
export const PoolSyncBar = () => { | ||
const { getPoolPerformanceTask } = usePoolPerformance(); | ||
|
||
// Get the pool performance task to determine if performance data is ready. | ||
const poolJoinPerformanceTask = getPoolPerformanceTask('pool_join'); | ||
|
||
// Calculate syncing status. | ||
const { startEra, currentEra, endEra } = poolJoinPerformanceTask; | ||
const totalEras = startEra.minus(endEra); | ||
const erasPassed = startEra.minus(currentEra); | ||
const percentPassed = erasPassed.isEqualTo(0) | ||
? new BigNumber(0) | ||
: erasPassed.dividedBy(totalEras).multipliedBy(100); | ||
|
||
return ( | ||
<div className="loader"> | ||
<div> | ||
<span | ||
className="progress" | ||
style={{ width: `${percentPassed}%` }} | ||
></span> | ||
</div> | ||
</div> | ||
); | ||
}; |