1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Add random int utility function

This commit is contained in:
Bill Thornton 2023-03-14 01:32:36 -04:00
parent ff8b7427e3
commit 4937f2d60c
4 changed files with 17 additions and 17 deletions

View file

@ -1,3 +1,5 @@
import { randomInt } from '../../utils/number.ts';
let currentId = 0;
function addUniquePlaylistItemId(item) {
if (!item.PlaylistItemId) {
@ -56,7 +58,7 @@ class PlayQueueManager {
const currentPlaylistItem = this._playlist.splice(this.getCurrentPlaylistIndex(), 1)[0];
for (let i = this._playlist.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * i);
const j = randomInt(0, i - 1);
const temp = this._playlist[i];
this._playlist[i] = this._playlist[j];
this._playlist[j] = temp;