From 80069be72238a18af6631d572cd243965eb8530e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Sat, 19 Jul 2025 13:38:11 -0500 Subject: [PATCH] Signed-off-by: Matt Bruce --- src/components/common/SongItem.tsx | 3 ++- src/hooks/useSongOperations.ts | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/common/SongItem.tsx b/src/components/common/SongItem.tsx index 218a5ec..757c640 100644 --- a/src/components/common/SongItem.tsx +++ b/src/components/common/SongItem.tsx @@ -4,6 +4,7 @@ import { add, heart, heartOutline, trash, informationCircle } from 'ionicons/ico import ActionButton from './ActionButton'; import { useAppSelector } from '../../redux'; import { selectQueue, selectFavorites } from '../../redux'; +import { debugLog } from '../../utils/logger'; import type { SongItemProps, QueueItem, Song } from '../../types'; // Utility function to extract filename from path @@ -218,7 +219,7 @@ const SongItem: React.FC = ({ const isInFavorites = (Object.values(favorites) as Song[]).some(favSong => favSong.path === song.path); // Debug logging for favorites - console.log('SongItem render:', { + debugLog('SongItem render:', { songTitle: song.title, songPath: song.path, favoritesCount: Object.keys(favorites).length, diff --git a/src/hooks/useSongOperations.ts b/src/hooks/useSongOperations.ts index 0c4ac43..7e9e52c 100644 --- a/src/hooks/useSongOperations.ts +++ b/src/hooks/useSongOperations.ts @@ -2,9 +2,10 @@ import { useCallback } from 'react'; import { useAppSelector } from '../redux'; import { selectControllerName, selectCurrentSinger, selectQueueObject } from '../redux'; import { queueService, favoritesService } from '../firebase/services'; -import type { Song, QueueItem } from '../types'; import { ref, get } from 'firebase/database'; import { database } from '../firebase/config'; +import { debugLog } from '../utils/logger'; +import type { Song, QueueItem } from '../types'; export const useSongOperations = () => { const controllerName = useAppSelector(selectControllerName); @@ -59,14 +60,14 @@ export const useSongOperations = () => { } try { - console.log('toggleFavorite called for song:', song.title, song.path); + debugLog('toggleFavorite called for song:', song.title, song.path); // Check if the song is currently in favorites by looking it up const favoritesRef = ref(database, `controllers/${controllerName}/favorites`); const snapshot = await get(favoritesRef); const favorites = snapshot.exists() ? snapshot.val() : {}; - console.log('Current favorites:', favorites); + debugLog('Current favorites:', favorites); // Find if this song is already in favorites by matching the path const existingFavoriteKey = Object.keys(favorites).find(key => { @@ -74,19 +75,19 @@ export const useSongOperations = () => { return favoriteSong && favoriteSong.path === song.path; }); - console.log('Existing favorite key:', existingFavoriteKey); + debugLog('Existing favorite key:', existingFavoriteKey); if (existingFavoriteKey) { // Remove from favorites - console.log('Removing from favorites'); + debugLog('Removing from favorites'); await favoritesService.removeFromFavorites(controllerName, existingFavoriteKey); } else { // Add to favorites - console.log('Adding to favorites'); + debugLog('Adding to favorites'); await favoritesService.addToFavorites(controllerName, song); } - console.log('toggleFavorite completed'); + debugLog('toggleFavorite completed'); } catch (error) { console.error('Failed to toggle favorite:', error); throw error;