@@ -34,30 +34,20 @@ export default function CandlestickChart({
3434 const [ loading , setLoading ] = useState ( false ) ;
3535 const prevOhlcDataLength = useRef < number > ( data ?. length ?? 0 ) ;
3636
37- console . log ( '=====liveOhlcv' , liveOhlcv ) ;
38-
3937 // Fetch OHLC data when period changes
4038 const fetchOHLCData = async ( selectedPeriod : Period ) => {
4139 setLoading ( true ) ;
4240 try {
4341 const config = PERIOD_CONFIG [ selectedPeriod ] ;
44- console . log ( '==== Fetching OHLC:' , {
45- period : selectedPeriod ,
46- days : config . days ,
47- interval : config . interval ,
48- coinId,
49- } ) ;
42+
5043 const newData = await getCoinOHLC (
5144 coinId ,
5245 config . days ,
5346 'usd' ,
5447 config . interval ,
5548 'full'
5649 ) ;
57- console . log ( '==== OHLC Fetched:' , {
58- period : selectedPeriod ,
59- dataPoints : newData ?. length ,
60- } ) ;
50+
6151 setOhlcData ( newData ?? [ ] ) ;
6252 } catch ( err ) {
6353 console . error ( 'Failed to fetch OHLC data:' , err ) ;
@@ -69,7 +59,6 @@ export default function CandlestickChart({
6959 const handlePeriodChange = ( newPeriod : Period ) => {
7060 if ( newPeriod === period ) return ;
7161
72- console . log ( '==== Period Change:' , { from : period , to : newPeriod , mode } ) ;
7362 setPeriod ( newPeriod ) ;
7463 fetchOHLCData ( newPeriod ) ;
7564 } ;
@@ -104,18 +93,13 @@ export default function CandlestickChart({
10493 chartRef . current = null ;
10594 candleSeriesRef . current = null ;
10695 } ;
96+ // eslint-disable-next-line react-hooks/exhaustive-deps
10797 } , [ height ] ) ;
10898
10999 // Update chart when data or liveOhlcv changes
110100 useEffect ( ( ) => {
111101 if ( ! candleSeriesRef . current ) return ;
112102
113- console . log ( '==== Chart Update Effect Triggered:' , {
114- ohlcDataPoints : ohlcData . length ,
115- hasLiveOhlcv : ! ! liveOhlcv ,
116- liveOhlcv,
117- } ) ;
118-
119103 // Convert timestamps from milliseconds to seconds
120104 const convertedToSeconds = ohlcData . map (
121105 ( item ) =>
@@ -129,7 +113,6 @@ export default function CandlestickChart({
129113 ) ;
130114
131115 let merged : OHLCData [ ] ;
132- let action = 'none' ;
133116
134117 if ( liveOhlcv ) {
135118 const liveTimestamp = liveOhlcv [ 0 ] ;
@@ -141,19 +124,10 @@ export default function CandlestickChart({
141124 if ( lastHistoricalCandle && lastHistoricalCandle [ 0 ] === liveTimestamp ) {
142125 // Update the last candle with live data
143126 merged = [ ...convertedToSeconds . slice ( 0 , - 1 ) , liveOhlcv ] ;
144- action = 'updated' ;
145127 } else {
146128 // Append new live candle
147129 merged = [ ...convertedToSeconds , liveOhlcv ] ;
148- action = 'appended' ;
149130 }
150-
151- console . log ( '==== Live OHLCV Merge:' , {
152- action,
153- liveTimestamp,
154- liveTime : new Date ( liveTimestamp * 1000 ) . toISOString ( ) ,
155- lastHistoricalTimestamp : lastHistoricalCandle ?. [ 0 ] ,
156- } ) ;
157131 } else {
158132 merged = convertedToSeconds ;
159133 }
0 commit comments