Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

LIVE-886 (Market): add sparkline variation + fix issue in countervalue initial value #1700

Merged
merged 3 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/market/MarketDataProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ export const MarketDataProvider = ({
}, []);

useEffect(() => {
if (countervalue)
if (countervalue) {
const ticker = countervalue.ticker.toLowerCase();
api.supportedCounterCurrencies().then(
(supportedCounterCurrencies) =>
api.setSupportedCoinsList().then((coins) => {
Expand All @@ -233,13 +234,14 @@ export const MarketDataProvider = ({
});
dispatch({
type: ACTIONS.UPDATE_COUNTERVALUE,
payload: supportedCounterCurrencies.includes(countervalue.ticker)
? countervalue.ticker
payload: supportedCounterCurrencies.includes(ticker)
? ticker
: "usd",
});
}, handleError),
handleError
);
}
}, [api, countervalue, handleError]);

useEffect(() => {
Expand Down
3 changes: 3 additions & 0 deletions src/market/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const matchSearch =
};

function distributedCopy(items: number[], n: number): number[] {
if (!items) return [];
if (items.length <= n) return items;
LFBarreto marked this conversation as resolved.
Show resolved Hide resolved
const elements = [items[0]];
const totalItems = items.length - 2;
const interval = Math.floor(totalItems / (n - 2));
Expand Down Expand Up @@ -83,6 +85,7 @@ function sparklineAsSvgData(points: number[]): SparklineSvgData {
})
.join(" "),
viewBox: `0 0 ${totalXSteps} ${sparklineYHeight + 3}`,
isPositive: points[0] <= points[points.length - 1],
LFBarreto marked this conversation as resolved.
Show resolved Hide resolved
};
}

Expand Down
1 change: 1 addition & 0 deletions src/market/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type MarketCurrencyChartDataRequestParams = {
export type SparklineSvgData = {
path: string;
viewBox: string;
isPositive: boolean;
};

export type CurrencyData = {
Expand Down