1- import cloneDeep from ' lodash.clonedeep' ;
2- import isPublished from ' ../util/isPublished' ;
3- import logger from ' ../logger/logger' ;
4- import ApiHelper from ' ./api-helper' ;
1+ import cloneDeep from " lodash.clonedeep" ;
2+ import isPublished from " ../util/isPublished" ;
3+ import logger from " ../logger/logger" ;
4+ import ApiHelper from " ./api-helper" ;
55
66/**
77 * PullStrategy.
@@ -18,7 +18,7 @@ class PullStrategy {
1818 interval ;
1919
2020 // Path to screen that should be loaded data for.
21- entryPoint = '' ;
21+ entryPoint = "" ;
2222
2323 /**
2424 * Constructor.
@@ -34,7 +34,7 @@ class PullStrategy {
3434 this . interval = config ?. interval ?? 60000 * 5 ;
3535 this . entryPoint = config . entryPoint ;
3636
37- this . apiHelper = new ApiHelper ( config . endpoint ?? '' ) ;
37+ this . apiHelper = new ApiHelper ( config . endpoint ?? "" ) ;
3838 }
3939
4040 /**
@@ -49,16 +49,16 @@ class PullStrategy {
4949 try {
5050 const response = await this . apiHelper . getPath ( screen . inScreenGroups ) ;
5151
52- if ( Object . prototype . hasOwnProperty . call ( response , ' hydra:member' ) ) {
52+ if ( Object . prototype . hasOwnProperty . call ( response , " hydra:member" ) ) {
5353 const promises = [ ] ;
5454
55- response [ ' hydra:member' ] . forEach ( ( group ) => {
55+ response [ " hydra:member" ] . forEach ( ( group ) => {
5656 promises . push ( this . apiHelper . getAllResultsFromPath ( group . campaigns ) ) ;
5757 } ) ;
5858
5959 await Promise . allSettled ( promises ) . then ( ( results ) => {
6060 results . forEach ( ( result ) => {
61- if ( result . status === ' fulfilled' ) {
61+ if ( result . status === " fulfilled" ) {
6262 result . value . results . forEach ( ( { campaign } ) => {
6363 screenGroupCampaigns . push ( campaign ) ;
6464 } ) ;
@@ -74,11 +74,11 @@ class PullStrategy {
7474
7575 try {
7676 const screenCampaignsResponse = await this . apiHelper . getPath (
77- screen . campaigns
77+ screen . campaigns ,
7878 ) ;
7979
80- screenCampaigns = screenCampaignsResponse [ ' hydra:member' ] . map (
81- ( { campaign } ) => campaign
80+ screenCampaigns = screenCampaignsResponse [ " hydra:member" ] . map (
81+ ( { campaign } ) => campaign ,
8282 ) ;
8383 } catch ( err ) {
8484 logger . error ( err ) ;
@@ -109,13 +109,13 @@ class PullStrategy {
109109 Promise . allSettled ( promises )
110110 . then ( ( results ) => {
111111 results . forEach ( ( result ) => {
112- if ( result . status === ' fulfilled' ) {
112+ if ( result . status === " fulfilled" ) {
113113 const members = result ?. value ?. results ?? [ ] ;
114114 const matches = result ?. value ?. path ?. match ( reg ) ?? [ ] ;
115115
116116 if ( matches ?. groups ?. regionId ) {
117117 regionData [ matches . groups . regionId ] = members . map (
118- ( { playlist } ) => playlist
118+ ( { playlist } ) => playlist ,
119119 ) ;
120120 }
121121 }
@@ -150,8 +150,8 @@ class PullStrategy {
150150 {
151151 regionKey,
152152 playlistKey,
153- }
154- )
153+ } ,
154+ ) ,
155155 ) ;
156156 }
157157 }
@@ -160,13 +160,13 @@ class PullStrategy {
160160 . then ( ( results ) => {
161161 results . forEach ( ( result ) => {
162162 if (
163- result . status === ' fulfilled' &&
164- Object . prototype . hasOwnProperty . call ( result . value , ' keys' )
163+ result . status === " fulfilled" &&
164+ Object . prototype . hasOwnProperty . call ( result . value , " keys" )
165165 ) {
166166 regionData [ result . value . keys . regionKey ] [
167167 result . value . keys . playlistKey
168168 ] . slidesData = result . value . results . map (
169- ( playlistSlide ) => playlistSlide . slide
169+ ( playlistSlide ) => playlistSlide . slide ,
170170 ) ;
171171 }
172172 } ) ;
@@ -189,7 +189,7 @@ class PullStrategy {
189189 screen = await this . apiHelper . getPath ( screenPath ) ;
190190 } catch ( err ) {
191191 logger . warn (
192- `Screen (${ screenPath } ) not loaded. Aborting content update.`
192+ `Screen (${ screenPath } ) not loaded. Aborting content update.` ,
193193 ) ;
194194
195195 return ;
@@ -233,7 +233,7 @@ class PullStrategy {
233233 logger . info ( `Has active campaign.` ) ;
234234
235235 // Create ulid to connect the campaign with the regions/playlists.
236- const campaignRegionId = ' 01G112XBWFPY029RYFB8X2H4KD' ;
236+ const campaignRegionId = " 01G112XBWFPY029RYFB8X2H4KD" ;
237237
238238 // Campaigns are always in full screen layout, for simplicity.
239239 newScreen . layoutData = {
@@ -243,8 +243,8 @@ class PullStrategy {
243243 } ,
244244 regions : [
245245 {
246- ' @id' : `/v2/layouts/regions/${ campaignRegionId } ` ,
247- gridArea : [ 'a' ] ,
246+ " @id" : `/v2/layouts/regions/${ campaignRegionId } ` ,
247+ gridArea : [ "a" ] ,
248248 } ,
249249 ] ,
250250 } ;
@@ -255,7 +255,7 @@ class PullStrategy {
255255 `/v2/screens/01FV9K4K0Y0X0K1J88SQ6B64VT/regions/${ campaignRegionId } /playlists` ,
256256 ] ;
257257 newScreen . regionData = await this . getSlidesForRegions (
258- newScreen . regionData
258+ newScreen . regionData ,
259259 ) ;
260260 } else {
261261 logger . info ( `Has no active campaign.` ) ;
@@ -317,7 +317,7 @@ class PullStrategy {
317317 ) {
318318 previousSlide = cloneDeep (
319319 this . lastestScreenData . regionData [ regionKey ] [ playlistKey ]
320- . slidesData [ slideKey ]
320+ . slidesData [ slideKey ] ,
321321 ) ;
322322 } else {
323323 previousSlide = { } ;
@@ -331,13 +331,13 @@ class PullStrategy {
331331 oldSlideChecksums === null ||
332332 newSlideChecksums . templateInfo !== oldSlideChecksums . templateInfo
333333 ) {
334- const templatePath = slide . templateInfo [ ' @id' ] ;
334+ const templatePath = slide . templateInfo [ " @id" ] ;
335335
336336 // Load template into slide.templateData.
337337 if (
338338 Object . prototype . hasOwnProperty . call (
339339 fetchedTemplates ,
340- templatePath
340+ templatePath ,
341341 )
342342 ) {
343343 slide . templateData = fetchedTemplates [ templatePath ] ;
@@ -356,7 +356,7 @@ class PullStrategy {
356356 // A slide cannot work without templateData. Mark as invalid.
357357 if ( slide . templateData === null ) {
358358 logger . warn (
359- `Template (${ slide . templateInfo [ ' @id' ] } ) not loaded, slideId: ${ slide [ ' @id' ] } `
359+ `Template (${ slide . templateInfo [ " @id" ] } ) not loaded, slideId: ${ slide [ " @id" ] } ` ,
360360 ) ;
361361 slide . invalid = true ;
362362 }
@@ -400,7 +400,7 @@ class PullStrategy {
400400 this . lastestScreenData = newScreen ;
401401
402402 // Deliver result to rendering
403- const event = new CustomEvent ( ' content' , {
403+ const event = new CustomEvent ( " content" , {
404404 detail : {
405405 screen : newScreen ,
406406 } ,
@@ -414,7 +414,7 @@ class PullStrategy {
414414
415415 async getTemplateData ( slide ) {
416416 return new Promise ( ( resolve ) => {
417- const templatePath = slide . templateInfo [ ' @id' ] ;
417+ const templatePath = slide . templateInfo [ " @id" ] ;
418418
419419 this . apiHelper . getPath ( templatePath ) . then ( ( data ) => {
420420 resolve ( data ) ;
@@ -454,7 +454,7 @@ class PullStrategy {
454454 // Start interval for pull periodically.
455455 this . activeInterval = setInterval (
456456 ( ) => this . getScreen ( this . entryPoint ) ,
457- this . interval
457+ this . interval ,
458458 ) ;
459459 } ) ;
460460 }
0 commit comments