diff --git a/src/common/controllers/ads-controller.js b/src/common/controllers/ads-controller.js index fff603855..31126f61b 100644 --- a/src/common/controllers/ads-controller.js +++ b/src/common/controllers/ads-controller.js @@ -324,18 +324,17 @@ class AdsController extends FakeEventTarget implements IAdsController { } const bumperCtrl = this._adsPluginControllers.find(controller => this._isBumper(controller)); const adCtrl = this._adsPluginControllers.find(controller => !this._isBumper(controller)); - const bumperCompletePromise = bumperCtrl && typeof bumperCtrl.onPlaybackEnded === 'function' ? bumperCtrl.onPlaybackEnded() : Promise.resolve(); - const adCompletePromise = adCtrl && typeof adCtrl.onPlaybackEnded === 'function' ? adCtrl.onPlaybackEnded() : Promise.resolve(); + const bumperCompleted = + bumperCtrl && typeof bumperCtrl.onPlaybackEnded === 'function' ? () => bumperCtrl.onPlaybackEnded() : () => Promise.resolve(); + const adCompleted = adCtrl && typeof adCtrl.onPlaybackEnded === 'function' ? () => adCtrl.onPlaybackEnded() : () => Promise.resolve(); if (!(this._adBreaksLayout.includes(-1) || this._adBreaksLayout.includes('100%'))) { this._allAdsCompleted = true; - } else { - const playbackEndedHandler = () => this._handleConfiguredPostroll(); - // $FlowFixMe - bumperCompletePromise.finally(() => { - // $FlowFixMe - adCompletePromise.finally(playbackEndedHandler); - }); } + // $FlowFixMe + bumperCompleted().finally(() => { + // $FlowFixMe + adCompleted().finally(() => this._handleConfiguredPostroll()); + }); } _onPlaybackEnded(): void {