Signed-off-by: mbrucedogs <mbrucedogs@gmail.com>
This commit is contained in:
parent
b8e8866681
commit
b28c362efc
@ -49,19 +49,10 @@ export const useActions = () => {
|
|||||||
if (!singer) throw new Error('No singer specified');
|
if (!singer) throw new Error('No singer specified');
|
||||||
// Calculate order
|
// Calculate order
|
||||||
const state = (window as unknown as { store?: { getState?: () => unknown } }).store?.getState?.();
|
const state = (window as unknown as { store?: { getState?: () => unknown } }).store?.getState?.();
|
||||||
let queueItems: Array<QueueItem & { key: string }> = [];
|
// Remove unused queueItems
|
||||||
if (state && typeof state === 'object' && 'queue' in state) {
|
// Always append new items to the end by using a high order number
|
||||||
const queueState = (state as { queue?: { data?: Record<string, QueueItem> } }).queue;
|
|
||||||
if (queueState && queueState.data && typeof queueState.data === 'object') {
|
|
||||||
queueItems = Object.entries(queueState.data).map(([key, item]) => ({ ...item, key }));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const maxOrder = queueItems.length > 0
|
|
||||||
? Math.max(...queueItems.map(item => item.order || 0))
|
|
||||||
: 0;
|
|
||||||
const nextOrder = maxOrder + 1;
|
|
||||||
const queueItem: Omit<QueueItem, 'key'> = {
|
const queueItem: Omit<QueueItem, 'key'> = {
|
||||||
order: nextOrder,
|
order: 1000,
|
||||||
singer: {
|
singer: {
|
||||||
name: singer.name,
|
name: singer.name,
|
||||||
lastLogin: singer.lastLogin || '',
|
lastLogin: singer.lastLogin || '',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user