| 518 | } |
| 519 | |
| 520 | async function Queue(list, context, type) { |
| 521 | const count = list.length; |
| 522 | |
| 523 | // Delimits the end of our list, as Spotify may add new context tracks to the queue |
| 524 | list.push("spotify:delimiter"); |
| 525 | |
| 526 | const { _queue, _client } = Spicetify.Platform.PlayerAPI._queue; |
| 527 | const { prevTracks, queueRevision } = _queue; |
| 528 | |
| 529 | // Format tracks with default values |
| 530 | const nextTracks = list.map((uri) => ({ |
| 531 | contextTrack: { |
| 532 | uri, |
| 533 | uid: "", |
| 534 | metadata: { |
| 535 | is_queued: "false", |
| 536 | }, |
| 537 | }, |
| 538 | removed: [], |
| 539 | blocked: [], |
| 540 | provider: "context", |
| 541 | })); |
| 542 | |
| 543 | // Lowest level setQueue method from vendor~xpui.js |
| 544 | _client.setQueue({ |
| 545 | nextTracks, |
| 546 | prevTracks, |
| 547 | queueRevision, |
| 548 | }); |
| 549 | |
| 550 | if (context) { |
| 551 | const { sessionId } = Spicetify.Platform.PlayerAPI.getState(); |
| 552 | Spicetify.Platform.PlayerAPI.updateContext(sessionId, { |
| 553 | uri: context, |
| 554 | url: `context://${context}`, |
| 555 | }); |
| 556 | } |
| 557 | |
| 558 | Spicetify.Player.next(); |
| 559 | |
| 560 | switch (type) { |
| 561 | case Type.ARTIST: |
| 562 | if (CONFIG.artistMode === "topTen") { |
| 563 | Spicetify.showNotification(`Shuffled Top ${count} Songs`); |
| 564 | break; |
| 565 | } |
| 566 | if (CONFIG.artistMode === "likedSongArtist") { |
| 567 | Spicetify.showNotification(`Shuffled ${count} Liked Songs`); |
| 568 | break; |
| 569 | } |
| 570 | if (CONFIG.artistMode === "single") { |
| 571 | Spicetify.showNotification(`Shuffled ${artistFetchTypeCount.single} Singles, Total of ${count} Songs`); |
| 572 | break; |
| 573 | } |
| 574 | if (CONFIG.artistMode === "album") { |
| 575 | Spicetify.showNotification(`Shuffled ${artistFetchTypeCount.album} Albums, Total of ${count} Songs`); |
| 576 | break; |
| 577 | } |