mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
Support for add items in custom position
This commit is contained in:
parent
8aa6913b72
commit
c3df679449
@ -20,7 +20,9 @@ export default class QueueManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (random) {
|
if (random) {
|
||||||
const randomIndex = Math.floor(Math.random() * this.nextItems.length)
|
const randomIndex = Math.floor(
|
||||||
|
Math.random() * this.nextItems.length,
|
||||||
|
)
|
||||||
|
|
||||||
this.currentItem = this.nextItems.splice(randomIndex, 1)[0]
|
this.currentItem = this.nextItems.splice(randomIndex, 1)[0]
|
||||||
} else {
|
} else {
|
||||||
@ -83,12 +85,16 @@ export default class QueueManager {
|
|||||||
return this.currentItem
|
return this.currentItem
|
||||||
}
|
}
|
||||||
|
|
||||||
add = (items) => {
|
add = (items, position = "end") => {
|
||||||
if (!Array.isArray(items)) {
|
if (!Array.isArray(items)) {
|
||||||
items = [items]
|
items = [items]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (position === "start") {
|
||||||
|
this.nextItems = [...items, ...this.nextItems]
|
||||||
|
} else {
|
||||||
this.nextItems = [...this.nextItems, ...items]
|
this.nextItems = [...this.nextItems, ...items]
|
||||||
|
}
|
||||||
|
|
||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user