Signed-off-by: mbrucedogs <mbrucedogs@gmail.com>
This commit is contained in:
parent
7d2369252e
commit
a326500100
@ -37,7 +37,7 @@ const SongInfo: React.FC<SongInfoProps> = ({ isOpen, onClose, song }) => {
|
||||
const isInQueue = (Object.values(queue) as QueueItem[]).some(queueItem => queueItem.song && queueItem.song.path === song.path);
|
||||
|
||||
const artistSongs = (Object.values(allSongs) as Song[]).filter(s =>
|
||||
s.artist.toLowerCase() === song.artist.toLowerCase() && s.path !== song.path
|
||||
(s.artist || '').toLowerCase() === (song.artist || '').toLowerCase() && s.path !== song.path
|
||||
);
|
||||
|
||||
const handleQueueSong = () => {
|
||||
|
||||
@ -15,7 +15,7 @@ export const useArtists = () => {
|
||||
const countsMap = new Map<string, number>();
|
||||
|
||||
allSongs.forEach(song => {
|
||||
const artist = song.artist.toLowerCase();
|
||||
const artist = (song.artist || '').toLowerCase();
|
||||
if (!songsMap.has(artist)) {
|
||||
songsMap.set(artist, []);
|
||||
countsMap.set(artist, 0);
|
||||
@ -34,12 +34,12 @@ export const useArtists = () => {
|
||||
|
||||
// Get songs by artist (now using cached data)
|
||||
const getSongsByArtist = useCallback((artistName: string) => {
|
||||
return songsByArtist.songsMap.get(artistName.toLowerCase()) || [];
|
||||
return songsByArtist.songsMap.get((artistName || '').toLowerCase()) || [];
|
||||
}, [songsByArtist.songsMap]);
|
||||
|
||||
// Get song count by artist (now using cached data)
|
||||
const getSongCountByArtist = useCallback((artistName: string) => {
|
||||
return songsByArtist.countsMap.get(artistName.toLowerCase()) || 0;
|
||||
return songsByArtist.countsMap.get((artistName || '').toLowerCase()) || 0;
|
||||
}, [songsByArtist.countsMap]);
|
||||
|
||||
return {
|
||||
|
||||
@ -49,11 +49,11 @@ export const usePaginatedData = <T>(
|
||||
// Simple search implementation - can be overridden by passing filtered items
|
||||
return allItems.filter((item: T) => {
|
||||
if (typeof item === 'string') {
|
||||
return item.toLowerCase().includes(searchTerm.toLowerCase());
|
||||
return (item || '').toLowerCase().includes((searchTerm || '').toLowerCase());
|
||||
}
|
||||
if (typeof item === 'object' && item !== null) {
|
||||
return Object.values(item as Record<string, unknown>).some(value =>
|
||||
String(value).toLowerCase().includes(searchTerm.toLowerCase())
|
||||
String(value || '').toLowerCase().includes((searchTerm || '').toLowerCase())
|
||||
);
|
||||
}
|
||||
return false;
|
||||
|
||||
@ -22,8 +22,8 @@ export const useSongLists = () => {
|
||||
|
||||
// Search for songs by artist and title
|
||||
const matchingSongs = allSongs.filter(song =>
|
||||
song.artist.toLowerCase() === songListSong.artist.toLowerCase() &&
|
||||
song.title.toLowerCase() === songListSong.title.toLowerCase()
|
||||
(song.artist || '').toLowerCase() === (songListSong.artist || '').toLowerCase() &&
|
||||
(song.title || '').toLowerCase() === (songListSong.title || '').toLowerCase()
|
||||
);
|
||||
|
||||
return matchingSongs;
|
||||
|
||||
@ -29,13 +29,13 @@ export const filterSongs = (songs: Song[], searchTerm: string, disabledSongPaths
|
||||
|
||||
if (!searchTerm.trim()) return filteredSongs;
|
||||
|
||||
const terms = searchTerm.toLowerCase().split(/\s+/).filter(term => term.length > 0);
|
||||
const terms = (searchTerm || '').toLowerCase().split(/\s+/).filter(term => term.length > 0);
|
||||
|
||||
if (terms.length === 0) return filteredSongs;
|
||||
|
||||
return filteredSongs.filter(song => {
|
||||
const songTitle = song.title.toLowerCase();
|
||||
const songArtist = song.artist.toLowerCase();
|
||||
const songTitle = (song.title || '').toLowerCase();
|
||||
const songArtist = (song.artist || '').toLowerCase();
|
||||
|
||||
// If only one term, use OR logic (title OR artist)
|
||||
if (terms.length === 1) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user