Signed-off-by: mbrucedogs <mbrucedogs@gmail.com>
This commit is contained in:
parent
8ad8201bfd
commit
b6aa7da1bf
@ -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<SelectSingerProps> = ({ 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;
|
||||
|
||||
@ -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}`), {
|
||||
|
||||
@ -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<QueueItem, 'key'> = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user