diff --git a/apps/block_scout_web/assets/js/lib/market_history_chart.js b/apps/block_scout_web/assets/js/lib/market_history_chart.js index 9d7c4a112e..1ca4137c57 100644 --- a/apps/block_scout_web/assets/js/lib/market_history_chart.js +++ b/apps/block_scout_web/assets/js/lib/market_history_chart.js @@ -80,12 +80,16 @@ function getDataFromLocalStorage (key) { return data ? JSON.parse(data) : [] } +function setDataToLocalStorage (key, data) { + window.localStorage.setItem(key, JSON.stringify(data)) +} + function getPriceData (marketHistoryData) { if (marketHistoryData.length === 0) { return getDataFromLocalStorage('priceData') } const data = marketHistoryData.map(({ date, closingPrice }) => ({ x: date, y: closingPrice })) - window.localStorage.setItem('priceData', JSON.stringify(data)) + setDataToLocalStorage('priceData', data) return data } @@ -99,7 +103,7 @@ function getMarketCapData (marketHistoryData, availableSupply) { : availableSupply return { x: date, y: closingPrice * supply } }) - window.localStorage.setItem('marketCapData', JSON.stringify(data)) + setDataToLocalStorage('marketCapData', data) return data }