Signed-off-by: mbrucedogs <mbrucedogs@gmail.com>

This commit is contained in:
mbrucedogs 2025-07-22 11:00:57 -05:00
parent 8ad8201bfd
commit b6aa7da1bf
3 changed files with 12 additions and 8 deletions

View File

@ -7,14 +7,13 @@ import {
IonLabel IonLabel
} from '@ionic/react'; } from '@ionic/react';
import { useAppSelector } from '../../redux'; import { useAppSelector } from '../../redux';
import { selectSingersArray, selectControllerName, selectQueueObject } from '../../redux'; import { selectSingersArray, selectControllerName } from '../../redux';
import { queueService } from '../../firebase/services';
import { useToast } from '../../hooks/useToast'; import { useToast } from '../../hooks/useToast';
import { useActions } from '../../hooks'; import { useActions } from '../../hooks';
import { ModalHeader } from './ModalHeader'; import { ModalHeader } from './ModalHeader';
import { NumberDisplay } from './NumberDisplay'; import { NumberDisplay } from './NumberDisplay';
import { SongInfoDisplay } from './SongItem'; import { SongInfoDisplay } from './SongItem';
import type { Song, Singer, QueueItem } from '../../types'; import type { Song, Singer } from '../../types';
interface SelectSingerProps { interface SelectSingerProps {
isOpen: boolean; isOpen: boolean;
@ -25,7 +24,6 @@ interface SelectSingerProps {
const SelectSinger: React.FC<SelectSingerProps> = ({ isOpen, onClose, song }) => { const SelectSinger: React.FC<SelectSingerProps> = ({ isOpen, onClose, song }) => {
const singers = useAppSelector(selectSingersArray); const singers = useAppSelector(selectSingersArray);
const controllerName = useAppSelector(selectControllerName); const controllerName = useAppSelector(selectControllerName);
const currentQueue = useAppSelector(selectQueueObject);
const toast = useToast(); const toast = useToast();
const showSuccess = toast?.showSuccess; const showSuccess = toast?.showSuccess;
const showError = toast?.showError; const showError = toast?.showError;

View File

@ -291,8 +291,14 @@ export const historyService = {
); );
if (existingEntry) { if (existingEntry) {
const [key, item] = 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}`), { await update(ref(database, `controllers/${controllerName}/history/${key}`), {
count: (item.count || 1) + 1, count,
lastPlayed: now, lastPlayed: now,
}); });
// Move this entry to the most recent by updating lastPlayed // Move this entry to the most recent by updating lastPlayed
@ -348,8 +354,10 @@ export const historyService = {
const [key, item] = existingEntry; const [key, item] = existingEntry;
let count = 1; let count = 1;
if (typeof item === 'object' && item !== null && 'count' in item) { 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(); const now = Date.now();
if (count > 1) { if (count > 1) {
await update(ref(database, `controllers/${controllerName}/history/${key}`), { await update(ref(database, `controllers/${controllerName}/history/${key}`), {

View File

@ -47,8 +47,6 @@ export const useActions = () => {
} }
} }
if (!singer) throw new Error('No singer specified'); if (!singer) throw new Error('No singer specified');
// Calculate order
const state = (window as unknown as { store?: { getState?: () => unknown } }).store?.getState?.();
// Remove unused queueItems // Remove unused queueItems
// Always append new items to the end by using a high order number // Always append new items to the end by using a high order number
const queueItem: Omit<QueueItem, 'key'> = { const queueItem: Omit<QueueItem, 'key'> = {