Skip to content

Commit

Permalink
fix cleanup of detection timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrylyzo committed Oct 25, 2023
1 parent 1d4bb28 commit eccf656
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/apiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ function redetectBitrate(instance) {
stopBitrateDetection(instance);

if (instance.accessToken() && instance.enableAutomaticBitrateDetection !== false) {
setTimeout(redetectBitrateInternal.bind(instance), 6000);
instance.detectTimeout = setTimeout(redetectBitrateInternal.bind(instance), 6000);
}
}

function redetectBitrateInternal() {
this.detectTimeout = null;

if (this.accessToken()) {
this.detectBitrate();
}
Expand All @@ -31,6 +33,7 @@ function redetectBitrateInternal() {
function stopBitrateDetection(instance) {
if (instance.detectTimeout) {
clearTimeout(instance.detectTimeout);
instance.detectTimeout = null;
}
}

Expand Down

0 comments on commit eccf656

Please sign in to comment.