|
|
@@ -133,22 +133,16 @@
|
|
|
|
|
|
let data = history;
|
|
|
|
|
|
- if (latestRes?.ok) {
|
|
|
- const latest = await latestRes.json();
|
|
|
- const lastHist = history[history.length - 1];
|
|
|
- if (new Date(latest.createdAt) > new Date(lastHist.createdAt)) {
|
|
|
- data = [...history, latest];
|
|
|
- }
|
|
|
- }
|
|
|
+ const latest = await latestRes.json();
|
|
|
|
|
|
if (data.length > 0) {
|
|
|
const first = data[0].price;
|
|
|
const lastEntry = data[data.length - 1];
|
|
|
|
|
|
- currentPrice = lastEntry.price;
|
|
|
- currentCurrency = lastEntry.currency || '';
|
|
|
+ currentPrice = latest.price;
|
|
|
+ currentCurrency = latest.currency || '';
|
|
|
priceChange = first !== 0 ? ((lastEntry.price - first) / first) * 100 : null;
|
|
|
- lastUpdated = new Date(lastEntry.createdAt);
|
|
|
+ lastUpdated = new Date(latest.updatedAt);
|
|
|
|
|
|
renderChart(data);
|
|
|
}
|