Skip to content

Commit 026c3b4

Browse files
Merge pull request #65 from compolabs/fix/1112-trades-overflow
1112: delete dynamic size for trades
2 parents edfd98b + 2bceba2 commit 026c3b4

File tree

2 files changed

+8
-38
lines changed

2 files changed

+8
-38
lines changed

src/screens/TradeScreen/OrderbookAndTradesInterface/SpotTrades/SpotTrades.tsx

+8-29
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useEffect } from "react";
1+
import React from "react";
22
import { useTheme } from "@emotion/react";
33
import styled from "@emotion/styled";
44
import { observer } from "mobx-react";
@@ -10,26 +10,12 @@ import {
1010
useSpotTradesVM,
1111
} from "@screens/TradeScreen/OrderbookAndTradesInterface/SpotTrades/SpotTradesVM";
1212
import { SmartFlex } from "@src/components/SmartFlex";
13-
import { useEventListener } from "@src/hooks/useEventListener";
14-
import { useMedia } from "@src/hooks/useMedia";
1513

1614
const SpotTradesImpl: React.FC = observer(() => {
1715
const vm = useSpotTradesVM();
1816
const theme = useTheme();
19-
const media = useMedia();
2017

21-
useEffect(() => {
22-
vm.calcSize(media.mobile);
23-
}, [media.mobile]);
24-
25-
const handleCalcSize = useCallback(() => {
26-
vm.calcSize(media.mobile);
27-
}, [media.mobile]);
28-
29-
useEventListener("resize", handleCalcSize);
30-
31-
const trades = vm.trades.slice(-vm.amountOfOrders);
32-
if (trades.length === 0)
18+
if (vm.trades.length === 0)
3319
return (
3420
<Root alignItems="center" justifyContent="center" mainAxisSize="stretch">
3521
<Text type={TEXT_TYPES.SUPPORTING}>No trades yet</Text>
@@ -46,7 +32,7 @@ const SpotTradesImpl: React.FC = observer(() => {
4632
</Header>
4733

4834
<Container className="better-scroll">
49-
{trades.map((trade) => (
35+
{vm.trades.map((trade) => (
5036
<Row key={"trade" + trade.id} alignItems="center" justifyContent="space-between" style={{ marginBottom: 2 }}>
5137
<Text color={theme.colors.textPrimary} type={TEXT_TYPES.BODY}>
5238
{trade.formatPrice}
@@ -74,6 +60,7 @@ export default SpotTrades;
7460

7561
const Root = styled(Column)`
7662
width: 100%;
63+
height: 100%;
7764
`;
7865

7966
const Header = styled.div`
@@ -90,21 +77,13 @@ const Header = styled.div`
9077
}
9178
`;
9279

93-
const Container = styled.div<{
94-
fitContent?: boolean;
95-
reverse?: boolean;
96-
}>`
97-
display: flex;
98-
flex-direction: column;
99-
justify-content: center;
80+
const Container = styled.div`
81+
display: grid;
10082
width: 100%;
101-
${({ fitContent }) => !fitContent && "height: 100%;"};
102-
${({ reverse }) => reverse && "flex-direction: column-reverse;"};
103-
height: 100%;
10483
box-sizing: border-box;
105-
padding: 54px 12px 0;
84+
padding: 5px 12px 0;
10685
overflow-y: auto;
107-
max-height: calc(100vh - 263px);
86+
max-height: calc(100vh - 260px);
10887
gap: 2px;
10988
`;
11089

src/screens/TradeScreen/OrderbookAndTradesInterface/SpotTrades/SpotTradesVM.tsx

-9
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ class SpotTradesVM {
2424

2525
private tradesUpdater: IntervalUpdater;
2626

27-
amountOfOrders: number = 0;
28-
setAmountOfOrders = (value: number) => (this.amountOfOrders = value);
29-
3027
constructor(private rootStore: RootStore) {
3128
makeAutoObservable(this);
3229
this.updateTrades().then();
@@ -36,12 +33,6 @@ class SpotTradesVM {
3633
this.tradesUpdater.run();
3734
}
3835

39-
calcSize = (isMobile: boolean) => {
40-
const orderbookHeight = isMobile ? 380 : window.innerHeight - 210;
41-
const rowHeight = 17;
42-
this.setAmountOfOrders(Math.floor((orderbookHeight - 24) / rowHeight));
43-
};
44-
4536
updateTrades = async () => {
4637
const { accountStore, tradeStore, initialized } = this.rootStore;
4738
const bcNetwork = FuelNetwork.getInstance();

0 commit comments

Comments
 (0)