Skip to content

Commit

Permalink
fix: Fix redundant calculation of remainingTime for ad UI. (googleads…
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnbuso authored Feb 26, 2018
1 parent b67a20d commit d8d70a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/ad-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};


Expand Down
2 changes: 1 addition & 1 deletion src/sdk-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ SdkImpl.prototype.onAdPlayheadTrackerInterval = function() {
}

this.controller.onAdPlayheadUpdated(
currentTime, duration, adPosition, totalAds);
currentTime, remainingTime, duration, adPosition, totalAds);
};


Expand Down

0 comments on commit d8d70a4

Please sign in to comment.