From d8d70a4a33c1c7f18fa24afb315117d5f42406ab Mon Sep 17 00:00:00 2001 From: Shawn Busolits Date: Mon, 26 Feb 2018 16:37:30 -0500 Subject: [PATCH] fix: Fix redundant calculation of remainingTime for ad UI. (#527) Resolves #526 --- src/ad-ui.js | 4 ++-- src/controller.js | 6 ++++-- src/sdk-impl.js | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ad-ui.js b/src/ad-ui.js index 79909a8f..6a7c202d 100644 --- a/src/ad-ui.js +++ b/src/ad-ui.js @@ -253,13 +253,13 @@ AdUi.prototype.onAdsPlaying = function() { * Takes data from the controller to update the UI. * * @param {number} currentTime Current time of the ad. + * @param {number} remainingTime Remaining time of the ad. * @param {number} duration Duration of the ad. * @param {number} adPosition Index of the ad in the pod. * @param {number} totalAds Total number of ads in the pod. */ AdUi.prototype.updateAdUi = - function(currentTime, duration, adPosition, totalAds) { - const remainingTime = duration - currentTime; + function(currentTime, remainingTime, duration, adPosition, totalAds) { // Update countdown timer data const remainingMinutes = Math.floor(remainingTime / 60); let remainingSeconds = Math.floor(remainingTime % 60); diff --git a/src/controller.js b/src/controller.js index 9c9b7956..85ee0afa 100644 --- a/src/controller.js +++ b/src/controller.js @@ -306,13 +306,15 @@ Controller.prototype.onAdsResumed = function() { * Takes data from the sdk impl and passes it to the ad UI to update the UI. * * @param {number} currentTime Current time of the ad. + * @param {number} remainingTime Remaining time of the ad. * @param {number} duration Duration of the ad. * @param {number} adPosition Index of the ad in the pod. * @param {number} totalAds Total number of ads in the pod. */ Controller.prototype.onAdPlayheadUpdated = - function(currentTime, duration, adPosition, totalAds) { - this.adUi.updateAdUi(currentTime, duration, adPosition, totalAds); + function(currentTime, remainingTime, duration, adPosition, totalAds) { + this.adUi.updateAdUi( + currentTime, remainingTime, duration, adPosition, totalAds); }; diff --git a/src/sdk-impl.js b/src/sdk-impl.js index 2ace1220..810f4a83 100644 --- a/src/sdk-impl.js +++ b/src/sdk-impl.js @@ -484,7 +484,7 @@ SdkImpl.prototype.onAdPlayheadTrackerInterval = function() { } this.controller.onAdPlayheadUpdated( - currentTime, duration, adPosition, totalAds); + currentTime, remainingTime, duration, adPosition, totalAds); };