Refactor code structure for improved readability and maintainability, removed unnecessary console logs, removed old.js
This commit is contained in:
@@ -353,13 +353,11 @@ export default function Player({ user }) {
|
||||
}, []);
|
||||
|
||||
const handleTrackData = useCallback((trackData) => {
|
||||
console.debug('handleTrackData called with:', trackData);
|
||||
const requestStation = activeStationRef.current;
|
||||
|
||||
// Only set "No track playing" if we have clear indication of no track
|
||||
// and not just missing song field (to avoid flickering during transitions)
|
||||
if ((!trackData.song || trackData.song === 'N/A') && (!trackData.artist || trackData.artist === 'N/A')) {
|
||||
console.debug('Setting no track playing state');
|
||||
setTrackTitle('No track playing');
|
||||
setLyrics([]);
|
||||
return;
|
||||
@@ -408,7 +406,6 @@ export default function Player({ user }) {
|
||||
const ws = new WebSocket(wsUrl);
|
||||
|
||||
ws.onopen = function () {
|
||||
console.log('Connected to radio WebSocket for station:', station);
|
||||
// Reset retry count on successful connection
|
||||
};
|
||||
|
||||
@@ -434,15 +431,12 @@ export default function Player({ user }) {
|
||||
};
|
||||
|
||||
ws.onclose = function (event) {
|
||||
console.log('Radio WebSocket connection closed, code:', event.code, 'reason:', event.reason);
|
||||
|
||||
// Don't retry if it was a clean close (code 1000)
|
||||
if (event.code === 1000) return;
|
||||
|
||||
// Attempt reconnection with exponential backoff
|
||||
if (retryCount < maxRetries) {
|
||||
const delay = Math.min(baseDelay * Math.pow(2, retryCount), maxDelay);
|
||||
console.log(`Attempting WebSocket reconnection in ${delay}ms (attempt ${retryCount + 1}/${maxRetries})`);
|
||||
|
||||
setTimeout(() => {
|
||||
connectWebSocket(retryCount + 1);
|
||||
|
||||
Reference in New Issue
Block a user