@@ -197,33 +197,38 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
197197 newGameName = newGameName ?? this . gameName
198198 if ( this . game ?. name !== newGameName || ! this . game ?. mainhash ) {
199199 this . fetchingData = false
200- return client . getGame ( { game : newGameName } , { source : BikeTagDefaults . gameSource } ) . then ( async ( r ) => {
201- if ( r . success ) {
202- const game = r . data as Game
203-
204- if ( game . settings [ 'data::aws' ] && game . settings [ 'data::aws' ] === 'true' ) {
205- this . imageSource = 'aws'
206- } else if ( game . settings [ 'data::imgur' ] && game . settings [ 'data::imgur' ] === 'true' ) {
207- this . imageSource = 'imgur'
208- }
209- /// TODO: split these up based on the imageSource?
210- biketagClientOpts . imgur . hash = game . mainhash
211- biketagClientOpts . imgur . queuehash = game . queuehash
212- biketagClientOpts . aws . region = game . awsRegion
213-
214- // TODO: set the default source to something else, now
215- const configuredClient = client . config ( biketagClientOpts , true , true )
216- debug ( `${ BikeTagDefaults . store } ::client-init` , { configuredClient, imageSource : this . imageSource } )
217-
218- return this . SET_GAME ( game )
219- } else {
220- const cachedGame = this . allGames . find ( ( g ) => g . name === newGameName )
221- if ( cachedGame ) {
222- return this . SET_GAME ( cachedGame )
200+ return client
201+ . getGame ( { game : newGameName } , { source : BikeTagDefaults . gameSource } )
202+ . then ( async ( r ) => {
203+ if ( r . success ) {
204+ const game = r . data as Game
205+
206+ if ( game . settings [ 'data::aws' ] && game . settings [ 'data::aws' ] === 'true' ) {
207+ this . imageSource = 'aws'
208+ } else if ( game . settings [ 'data::imgur' ] && game . settings [ 'data::imgur' ] === 'true' ) {
209+ this . imageSource = 'imgur'
210+ }
211+ /// TODO: split these up based on the imageSource?
212+ biketagClientOpts . imgur . hash = game . mainhash
213+ biketagClientOpts . imgur . queuehash = game . queuehash
214+ biketagClientOpts . aws . region = game . awsRegion
215+
216+ // TODO: set the default source to something else, now
217+ const configuredClient = client . config ( biketagClientOpts , true , true )
218+ debug ( `${ BikeTagDefaults . store } ::client-init` , {
219+ configuredClient,
220+ imageSource : this . imageSource ,
221+ } )
222+
223+ return this . SET_GAME ( game )
224+ } else {
225+ const cachedGame = this . allGames . find ( ( g ) => g . name === newGameName )
226+ if ( cachedGame ) {
227+ return this . SET_GAME ( cachedGame )
228+ }
223229 }
224- }
225- return false
226- } )
230+ return false
231+ } )
227232 }
228233 } ,
229234 async resetBikeTagCache ( ) {
@@ -313,7 +318,7 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
313318 return client
314319 . getAllGames ( undefined , {
315320 source : BikeTagDefaults . gameSource ,
316- cached
321+ cached,
317322 } )
318323 . then ( ( d ) => {
319324 if ( d . success ) {
@@ -340,34 +345,36 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
340345 } ,
341346 async fetchQueuedTags ( cached = true ) {
342347 if ( this . currentBikeTag ?. tagnumber > 0 ) {
343- return client . queue ( undefined , { source : cached ? this . imageSource : 'biketag' , cached } ) . then ( ( d ) => {
344- if ( ( d as Tag [ ] ) ?. length > 0 ) {
345- const currentBikeTagQueue : Tag [ ] = ( d as Tag [ ] ) . filter (
346- ( t ) =>
347- t . tagnumber > this . currentBikeTag . tagnumber ||
348- ( t . tagnumber === this . currentBikeTag . tagnumber && ! t . mysteryImageUrl ) ,
349- )
350-
351- /// Get the player queued tag by player id
352- const [ playerQueuedTag ] = currentBikeTagQueue . filter (
353- ( t ) => this . profile ?. sub && t . playerId === this . profile . sub ,
354- )
355-
356- if ( playerQueuedTag ) {
357- this . SET_QUEUED_TAG ( playerQueuedTag )
358- this . SET_QUEUED_TAG_STATE ( playerQueuedTag )
348+ return client
349+ . queue ( undefined , { source : cached ? this . imageSource : 'biketag' , cached } )
350+ . then ( ( d ) => {
351+ if ( ( d as Tag [ ] ) ?. length > 0 ) {
352+ const currentBikeTagQueue : Tag [ ] = ( d as Tag [ ] ) . filter (
353+ ( t ) =>
354+ t . tagnumber > this . currentBikeTag . tagnumber ||
355+ ( t . tagnumber === this . currentBikeTag . tagnumber && ! t . mysteryImageUrl ) ,
356+ )
357+
358+ /// Get the player queued tag by player id
359+ const [ playerQueuedTag ] = currentBikeTagQueue . filter (
360+ ( t ) => this . profile ?. sub && t . playerId === this . profile . sub ,
361+ )
362+
363+ if ( playerQueuedTag ) {
364+ this . SET_QUEUED_TAG ( playerQueuedTag )
365+ this . SET_QUEUED_TAG_STATE ( playerQueuedTag )
366+ } else {
367+ this . SET_QUEUED_TAG ( )
368+ this . SET_QUEUED_TAG_STATE ( )
369+ }
370+
371+ return this . SET_QUEUED_TAGS ( currentBikeTagQueue )
359372 } else {
360373 this . SET_QUEUED_TAG ( )
361374 this . SET_QUEUED_TAG_STATE ( )
375+ return this . SET_QUEUED_TAGS ( [ ] )
362376 }
363-
364- return this . SET_QUEUED_TAGS ( currentBikeTagQueue )
365- } else {
366- this . SET_QUEUED_TAG ( )
367- this . SET_QUEUED_TAG_STATE ( )
368- return this . SET_QUEUED_TAGS ( [ ] )
369- }
370- } )
377+ } )
371378 }
372379
373380 return false
@@ -621,14 +628,18 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
621628 }
622629 return client . deleteTag ( queuedMysteryTag , { source } ) . then ( async ( t ) => {
623630 if ( t . success ) {
624- debug ( `${ BikeTagDefaults . store } ::dequeue-mystery-tag` , 'mystery tag dequeued' )
631+ debug ( `${ BikeTagDefaults . store } ::dequeue-mystery-tag` , 'mystery tag dequeued' )
625632 await client . getQueue ( { reindex : true } , { source : 'biketag' } )
626633 this . SET_QUEUED_TAG ( queuedFoundTag )
627634 this . RESET_FORM_STEP_TO_MYSTERY ( )
628635
629636 return true
630637 } else {
631- debug ( `${ BikeTagDefaults . store } ::dequeue-mystery-tag` , 'dequeue BikeTag failed: ' + t . error , 'error' )
638+ debug (
639+ `${ BikeTagDefaults . store } ::dequeue-mystery-tag` ,
640+ 'dequeue BikeTag failed: ' + t . error ,
641+ 'error' ,
642+ )
632643 return t . error
633644 }
634645 } )
@@ -643,7 +654,11 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
643654 this . SET_QUEUE_FOUND ( t . data )
644655 await client . getQueue ( { resize : true , reindex : true } , { source : 'biketag' } )
645656 } else {
646- debug ( `${ BikeTagDefaults . store } ::queue-found-tag` , 'queue (Found) BikeTag failed: ' + t . error , 'error' )
657+ debug (
658+ `${ BikeTagDefaults . store } ::queue-found-tag` ,
659+ 'queue (Found) BikeTag failed: ' + t . error ,
660+ 'error' ,
661+ )
647662 return t . error
648663 }
649664 return t . success
@@ -660,7 +675,11 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
660675 this . SET_QUEUE_MYSTERY ( t . data )
661676 await client . getQueue ( { resize : true , reindex : true } , { source : 'biketag' } )
662677 } else {
663- debug ( `${ BikeTagDefaults . store } ::queue-mystery-tag` , 'queue (Mystery) BikeTag failed: ' + t . error , 'error' )
678+ debug (
679+ `${ BikeTagDefaults . store } ::queue-mystery-tag` ,
680+ 'queue (Mystery) BikeTag failed: ' + t . error ,
681+ 'error' ,
682+ )
664683 return t . error
665684 }
666685 return t . success
@@ -677,7 +696,11 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
677696 this . SET_QUEUED_SUBMITTED ( t . data )
678697 await client . getQueue ( { resize : true , reindex : true } , { source : 'biketag' } )
679698 } else {
680- debug ( `${ BikeTagDefaults . store } ::queue-post-tag` , 'queue (Post) BikeTag failed: ' + t . error , 'error' )
699+ debug (
700+ `${ BikeTagDefaults . store } ::queue-post-tag` ,
701+ 'queue (Post) BikeTag failed: ' + t . error ,
702+ 'error' ,
703+ )
681704 return t . error
682705 }
683706 return t . success
@@ -1018,7 +1041,7 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
10181041 return ( url : string , s : string = 'm' ) =>
10191042 getImageSized ( state . imageSource , url , s as 's' | 'm' | 'l' | 'o' | undefined )
10201043 } ,
1021- getImageSource ( state ) {
1044+ getImageSource ( state ) {
10221045 return state . imageSource
10231046 } ,
10241047 getQueuedTagState : ( state ) => {
0 commit comments