Add a button to manually refresh data on the deprecated markets page

This commit is contained in:
Nishad 2020-09-22 16:32:29 +08:00
parent 14d9a1118e
commit 622820a935
1 changed files with 9 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import FloatingElement from './layout/FloatingElement';
import CheckOutlined from '@ant-design/icons/lib/icons/CheckOutlined'; import CheckOutlined from '@ant-design/icons/lib/icons/CheckOutlined';
import BalancesTable from './UserInfoTable/BalancesTable'; import BalancesTable from './UserInfoTable/BalancesTable';
import OpenOrderTable from './UserInfoTable/OpenOrderTable'; import OpenOrderTable from './UserInfoTable/OpenOrderTable';
import SyncOutlined from '@ant-design/icons/lib/icons/SyncOutlined';
const { Title } = Typography; const { Title } = Typography;
@ -19,6 +20,7 @@ export default function DeprecatedMarketsInstructions({ switchToLiveMarkets }) {
loaded, loaded,
refreshOpenOrders, refreshOpenOrders,
} = useGetOpenOrdersForDeprecatedMarkets(); } = useGetOpenOrdersForDeprecatedMarkets();
const { refresh } = useUnmigratedOpenOrdersAccounts(); const { refresh } = useUnmigratedOpenOrdersAccounts();
const needToCancelOrders = !openOrders || openOrders.length > 0; const needToCancelOrders = !openOrders || openOrders.length > 0;
const filteredBalances = const filteredBalances =
@ -39,6 +41,11 @@ export default function DeprecatedMarketsInstructions({ switchToLiveMarkets }) {
To migrate over to the new markets, please cancel your orders and settle To migrate over to the new markets, please cancel your orders and settle
your funds on old markets. your funds on old markets.
</Typography> </Typography>
<div style={{ marginTop: 20, display: 'flex', justifyContent: 'center' }}>
<Button onClick={() => refresh(true)}>
<SyncOutlined /> Refresh data
</Button>
</div>
{!balances ? ( {!balances ? (
<Spin size="large" /> <Spin size="large" />
) : ( ) : (
@ -54,7 +61,7 @@ export default function DeprecatedMarketsInstructions({ switchToLiveMarkets }) {
setTimeout(() => { setTimeout(() => {
refresh(); refresh();
refreshOpenOrders(); refreshOpenOrders();
}, 1500); // Wait so that on-chain account state reflects the update }, 1000); // Wait so that on-chain account state reflects the update
}} }}
/> />
) : ( ) : (
@ -70,7 +77,7 @@ export default function DeprecatedMarketsInstructions({ switchToLiveMarkets }) {
hideWalletBalance hideWalletBalance
showMarket showMarket
onSettleSuccess={() => { onSettleSuccess={() => {
setTimeout(refresh, 1500); // Wait so that on-chain account state reflects the update setTimeout(refresh, 1000); // Wait so that on-chain account state reflects the update
}} }}
/> />
)} )}