Skip to content

Commit efd9293

Browse files
committed
refactor: simplify DAI config normalization
1 parent 07ff48a commit efd9293

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/Video.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ import type {
5454
CmcdData,
5555
ReactVideoSource,
5656
AdConfig,
57+
AdConfigDAIVod,
58+
AdConfigDAILive,
5759
} from './types';
5860
import type {ISO639_1} from './types/language';
5961
import type {AdsConfig} from './specs/VideoNativeComponent';
@@ -68,18 +70,18 @@ function normalizeAdConfig(
6870
const adType = 'type' in ad ? ad.type : 'csai';
6971

7072
if (adType === 'dai') {
73+
const daiAd = ad as AdConfigDAIVod | AdConfigDAILive;
7174
return {
7275
type: 'dai',
73-
streamType: 'streamType' in ad ? ad.streamType : undefined,
74-
adLanguage: ad.adLanguage,
76+
streamType: daiAd.streamType,
77+
adLanguage: daiAd.adLanguage,
7578
contentSourceId:
76-
'contentSourceId' in ad ? ad.contentSourceId : undefined,
77-
videoId: 'videoId' in ad ? ad.videoId : undefined,
78-
assetKey: 'assetKey' in ad ? ad.assetKey : undefined,
79-
format: 'format' in ad ? ad.format : undefined,
80-
adTagParameters:
81-
'adTagParameters' in ad ? ad.adTagParameters : undefined,
82-
fallbackUri: 'fallbackUri' in ad ? ad.fallbackUri : undefined,
79+
'contentSourceId' in daiAd ? daiAd.contentSourceId : undefined,
80+
videoId: 'videoId' in daiAd ? daiAd.videoId : undefined,
81+
assetKey: 'assetKey' in daiAd ? daiAd.assetKey : undefined,
82+
format: daiAd.format,
83+
adTagParameters: daiAd.adTagParameters,
84+
fallbackUri: daiAd.fallbackUri,
8385
};
8486
}
8587

0 commit comments

Comments
 (0)