diff --git a/src/components/common/SelectSinger.tsx b/src/components/common/SelectSinger.tsx index ebd1f59..acd70ec 100644 --- a/src/components/common/SelectSinger.tsx +++ b/src/components/common/SelectSinger.tsx @@ -7,14 +7,13 @@ import { IonLabel } from '@ionic/react'; import { useAppSelector } from '../../redux'; -import { selectSingersArray, selectControllerName, selectQueueObject } from '../../redux'; -import { queueService } from '../../firebase/services'; +import { selectSingersArray, selectControllerName } from '../../redux'; import { useToast } from '../../hooks/useToast'; import { useActions } from '../../hooks'; import { ModalHeader } from './ModalHeader'; import { NumberDisplay } from './NumberDisplay'; import { SongInfoDisplay } from './SongItem'; -import type { Song, Singer, QueueItem } from '../../types'; +import type { Song, Singer } from '../../types'; interface SelectSingerProps { isOpen: boolean; @@ -25,7 +24,6 @@ interface SelectSingerProps { const SelectSinger: React.FC = ({ isOpen, onClose, song }) => { const singers = useAppSelector(selectSingersArray); const controllerName = useAppSelector(selectControllerName); - const currentQueue = useAppSelector(selectQueueObject); const toast = useToast(); const showSuccess = toast?.showSuccess; const showError = toast?.showError; diff --git a/src/firebase/services.ts b/src/firebase/services.ts index 00fe50c..0c5b483 100644 --- a/src/firebase/services.ts +++ b/src/firebase/services.ts @@ -291,8 +291,14 @@ export const historyService = { ); if (existingEntry) { const [key, item] = existingEntry; + let count = 1; + if (typeof item === 'object' && item !== null && 'count' in item) { + const itemObj = item as { count?: number }; + count = typeof itemObj.count === 'number' ? itemObj.count : 1; + } + count = count + 1; await update(ref(database, `controllers/${controllerName}/history/${key}`), { - count: (item.count || 1) + 1, + count, lastPlayed: now, }); // Move this entry to the most recent by updating lastPlayed @@ -348,8 +354,10 @@ export const historyService = { const [key, item] = existingEntry; let count = 1; if (typeof item === 'object' && item !== null && 'count' in item) { - count = (item as { count?: number }).count ?? 1; + const itemWithCount = item as { count?: number }; + count = typeof itemWithCount.count === 'number' ? itemWithCount.count : 1; } + count = count + 1; const now = Date.now(); if (count > 1) { await update(ref(database, `controllers/${controllerName}/history/${key}`), { diff --git a/src/hooks/useActions.ts b/src/hooks/useActions.ts index d3ca7a5..2365c16 100644 --- a/src/hooks/useActions.ts +++ b/src/hooks/useActions.ts @@ -47,8 +47,6 @@ export const useActions = () => { } } if (!singer) throw new Error('No singer specified'); - // Calculate order - const state = (window as unknown as { store?: { getState?: () => unknown } }).store?.getState?.(); // Remove unused queueItems // Always append new items to the end by using a high order number const queueItem: Omit = {