Ignore double loads (fixes #84)

This commit is contained in:
Marks Polakovs 2020-04-20 16:08:12 +02:00
parent 60ddc1fc89
commit f85c7b1a65

View file

@ -6,7 +6,7 @@ import {
} from "@reduxjs/toolkit"; } from "@reduxjs/toolkit";
import fetchProgress, { FetchProgressData } from "fetch-progress"; import fetchProgress, { FetchProgressData } from "fetch-progress";
import Between from "between.js"; import Between from "between.js";
import { PlanItem } from "../showplanner/state"; import { itemId, PlanItem } from "../showplanner/state";
import * as BroadcastState from "../broadcast/state"; import * as BroadcastState from "../broadcast/state";
import Keys from "keymaster"; import Keys from "keymaster";
import { Track, MYRADIO_NON_API_BASE, AuxItem } from "../api"; import { Track, MYRADIO_NON_API_BASE, AuxItem } from "../api";
@ -327,6 +327,11 @@ export const load = (
return; return;
} }
} }
// If this is already the currently loaded item, don't bother
const currentItem = getState().mixer.players[player].loadedItem;
if (currentItem !== null && itemId(currentItem) === itemId(item)) {
return;
}
// If we're already loading something, abort it // If we're already loading something, abort it
if (typeof loadAbortControllers[player] !== "undefined") { if (typeof loadAbortControllers[player] !== "undefined") {
loadAbortControllers[player].abort(); loadAbortControllers[player].abort();