mirror of
https://github.com/Jellify-Music/App.git
synced 2025-12-21 10:39:59 -06:00
Fix Add to Queue Issues (#457)
* fix issue where items added to queue weren't always queued * On Repeat and Recently Played Sections in CarPlay now load tracks into the queue and start playback
This commit is contained in:
@@ -32,113 +32,129 @@ describe('Queue Index Util', () => {
|
||||
|
||||
describe('findPlayQueueIndexStart', () => {
|
||||
it('should return the index of the first track that is not from selection', async () => {
|
||||
const result = await findPlayQueueIndexStart([
|
||||
{
|
||||
id: '1',
|
||||
index: 0,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '1' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
index: 1,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '2' },
|
||||
QueuingType: QueuingType.PlayingNext,
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
index: 2,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '3' },
|
||||
QueuingType: QueuingType.DirectlyQueued,
|
||||
},
|
||||
])
|
||||
const result = await findPlayQueueIndexStart(
|
||||
[
|
||||
{
|
||||
id: '1',
|
||||
index: 0,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '1' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
index: 1,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '2' },
|
||||
QueuingType: QueuingType.PlayingNext,
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
index: 2,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '3' },
|
||||
QueuingType: QueuingType.DirectlyQueued,
|
||||
},
|
||||
],
|
||||
0,
|
||||
)
|
||||
|
||||
expect(result).toBe(3)
|
||||
})
|
||||
|
||||
it('should return the index of the first track that is not from selection and after other queued tracks', async () => {
|
||||
const result = await findPlayQueueIndexStart([
|
||||
{
|
||||
id: '1',
|
||||
index: 0,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '1' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
index: 1,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '2' },
|
||||
QueuingType: QueuingType.PlayingNext,
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
index: 2,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '3' },
|
||||
QueuingType: QueuingType.DirectlyQueued,
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
index: 3,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '4' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
{
|
||||
id: '5',
|
||||
index: 4,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '5' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
])
|
||||
const result = await findPlayQueueIndexStart(
|
||||
[
|
||||
{
|
||||
id: '1',
|
||||
index: 0,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '1' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
index: 1,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '2' },
|
||||
QueuingType: QueuingType.PlayingNext,
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
index: 2,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '3' },
|
||||
QueuingType: QueuingType.DirectlyQueued,
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
index: 3,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '4' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
{
|
||||
id: '5',
|
||||
index: 4,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '5' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
],
|
||||
0,
|
||||
)
|
||||
|
||||
expect(result).toBe(3)
|
||||
})
|
||||
|
||||
it('should add in relation to the active track if shuffled, but respect queue priority', async () => {
|
||||
const result = await findPlayQueueIndexStart([
|
||||
{
|
||||
id: '2',
|
||||
index: 0,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '2' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
{
|
||||
id: '1',
|
||||
index: 1,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '1' },
|
||||
QueuingType: QueuingType.PlayingNext,
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
index: 2,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '3' },
|
||||
QueuingType: QueuingType.DirectlyQueued,
|
||||
},
|
||||
{
|
||||
id: '5',
|
||||
index: 3,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '5' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
index: 4,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '4' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
])
|
||||
const result = await findPlayQueueIndexStart(
|
||||
[
|
||||
{
|
||||
id: '2',
|
||||
index: 0,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '2' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
{
|
||||
id: '1',
|
||||
index: 1,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '1' },
|
||||
QueuingType: QueuingType.PlayingNext,
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
index: 2,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '3' },
|
||||
QueuingType: QueuingType.DirectlyQueued,
|
||||
},
|
||||
{
|
||||
id: '5',
|
||||
index: 3,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '5' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
index: 4,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '4' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
{
|
||||
id: '6',
|
||||
index: 5,
|
||||
url: 'https://example.com',
|
||||
item: { Id: '6' },
|
||||
QueuingType: QueuingType.FromSelection,
|
||||
},
|
||||
],
|
||||
0,
|
||||
)
|
||||
|
||||
expect(result).toBe(3)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user