@ -111,40 +111,44 @@ namespace PlexRequests.UI.Helpers
return false ;
}
}
var addedArtist = index . FirstOrDefault ( x = > x . ArtistID = = request . ArtistId ) ;
var artistName = addedArtist ? . ArtistName ? ? string . Empty ;
while ( artistName . Contains ( "Fetch failed" ) )
counter = 0 ;
var artistStatus = index . Where ( x = > x . ArtistID = = request . ArtistId ) . Select ( x = > x . Status ) . FirstOrDefault ( ) ;
while ( artistStatus ! = "Active" )
{
Thread . Sleep ( WaitTime ) ;
await Api . RefreshArtist ( Settings . ApiKey , Settings . FullUri , request . ArtistId ) ;
counter + + ;
Log . Trace ( "Artist status {1}. Counter = {0}" , counter , artistStatus ) ;
index = await Api . GetIndex ( Settings . ApiKey , Settings . FullUri ) ;
artistName = index ? . FirstOrDefault ( x = > x . ArtistID = = request . ArtistId ) ? . ArtistName ? ? string . Empty ;
artistStatus = index . Where ( x = > x . ArtistID = = request . ArtistId ) . Select ( x = > x . Status ) . FirstOrDefault ( ) ;
if ( counter > CounterMax )
{
Log . Trace ( "Artist fetch has failed . Counter = {0}. Returning false", counter ) ;
Log . Warn ( " Artist in headphones fetch has failed, we have tried refreshing the artist but no luck .") ;
Log . Trace ( "Artist status is still not active . Counter = {0}. Returning false", counter ) ;
Log . Warn ( " The artist status is still not Active. We have waited long enough, seems to be a big delay in headphones .") ;
return false ;
}
}
var addedArtist = index . FirstOrDefault ( x = > x . ArtistID = = request . ArtistId ) ;
var artistName = addedArtist ? . ArtistName ? ? string . Empty ;
counter = 0 ;
var artistStatus = index . Where ( x = > x . ArtistID = = request . ArtistId ) . Select ( x = > x . Status ) . FirstOrDefault ( ) ;
while ( artistStatus ! = "Active" )
while ( artistName . Contains ( "Fetch failed" ) )
{
Thread . Sleep ( WaitTime ) ;
counter + + ;
Log . Trace ( "Artist status {1}. Counter = {0}" , counter , artistStatus ) ;
await Api . RefreshArtist ( Settings . ApiKey , Settings . FullUri , request . ArtistId ) ;
index = await Api . GetIndex ( Settings . ApiKey , Settings . FullUri ) ;
artistStatus = index . Where ( x = > x . ArtistID = = request . ArtistId ) . Select ( x = > x . Status ) . FirstOrDefault ( ) ;
artistName = index ? . FirstOrDefault ( x = > x . ArtistID = = request . ArtistId ) ? . ArtistName ? ? string . Empty ;
counter + + ;
if ( counter > CounterMax )
{
Log . Trace ( "Artist status is still not active . Counter = {0}. Returning false", counter ) ;
Log . Warn ( " The artist status is still not Active. We have waited long enough, seems to be a big delay in headphones .") ;
Log . Trace ( "Artist fetch has failed . Counter = {0}. Returning false", counter ) ;
Log . Warn ( " Artist in headphones fetch has failed, we have tried refreshing the artist but no luck .") ;
return false ;
}
}
return true ;
}