77using System . Collections . Generic ;
88using System . Linq ;
99using System . Threading ;
10- using System . Threading . Tasks ;
1110using UnityEngine ;
1211using UnityEngine . Pool ;
1312using static DCLServices . WearablesCatalogService . WearableWithEntityResponseDto . ElementDto ;
@@ -56,26 +55,29 @@ public WearableCollectionResponse(EntityDto[] entities)
5655 private readonly Dictionary < ( string userId , string collectionId , int pageSize ) , LambdaResponsePagePointer < WearableWithDefinitionResponse > > thirdPartyCollectionPagePointers = new ( ) ;
5756 private readonly List < string > pendingWearablesToRequest = new ( ) ;
5857 private readonly BaseVariable < FeatureFlag > featureFlags ;
58+ private readonly DataStore dataStore ;
59+ private readonly ICatalyst catalyst ;
5960 private string assetBundlesUrl => featureFlags . Get ( ) . IsFeatureEnabled ( "ab-new-cdn" ) ? "https://ab-cdn.decentraland.org/" : "https://content-assets-as-bundle.decentraland.org/" ;
6061
6162 private CancellationTokenSource serviceCts ;
6263 private UniTaskCompletionSource < IReadOnlyList < WearableItem > > lastRequestSource ;
63- private ICatalyst catalyst ;
6464
6565#if UNITY_EDITOR
6666 private readonly DebugConfig debugConfig = DataStore . i . debugConfig ;
6767#endif
68+
6869 public LambdasWearablesCatalogService ( BaseDictionary < string , WearableItem > wearablesCatalog ,
6970 ILambdasService lambdasService ,
7071 IServiceProviders serviceProviders ,
71- BaseVariable < FeatureFlag > featureFlags )
72+ BaseVariable < FeatureFlag > featureFlags ,
73+ DataStore dataStore )
7274 {
7375 this . featureFlags = featureFlags ;
76+ this . dataStore = dataStore ;
7477 this . lambdasService = lambdasService ;
7578 this . serviceProviders = serviceProviders ;
7679 WearablesCatalog = wearablesCatalog ;
7780 catalyst = serviceProviders . catalyst ;
78-
7981 }
8082
8183 public void Initialize ( )
@@ -143,8 +145,20 @@ public void Dispose()
143145 foreach ( string collectionId in thirdPartyCollectionIds )
144146 queryParams . Add ( ( "thirdPartyCollectionId" , collectionId ) ) ;
145147
146- string lambdasUrl = await catalyst . GetLambdaUrl ( cancellationToken ) ;
147- string explorerUrl = lambdasUrl . Replace ( "/lambdas" , "/explorer" ) ;
148+ string explorerUrl ;
149+ string contentUrl ;
150+
151+ if ( IsLocalPreview ( ) )
152+ {
153+ explorerUrl = "https://peer.decentraland.org/explorer/" ;
154+ contentUrl = "https://peer.decentraland.org/content/contents/" ;
155+ }
156+ else
157+ {
158+ string lambdasUrl = await catalyst . GetLambdaUrl ( cancellationToken ) ;
159+ explorerUrl = lambdasUrl . Replace ( "/lambdas" , "/explorer" ) ;
160+ contentUrl = $ "{ catalyst . contentUrl } /contents/";
161+ }
148162
149163 ( WearableWithEntityResponseDto response , bool success ) = await lambdasService . GetFromSpecificUrl < WearableWithEntityResponseDto > (
150164 $ "{ explorerUrl } /:userId/wearables",
@@ -156,7 +170,7 @@ public void Dispose()
156170 throw new Exception ( $ "The request of wearables for '{ userId } ' failed!") ;
157171
158172 List < WearableItem > wearables = ValidateWearables ( response . elements ,
159- $ " { catalyst . contentUrl } /contents/" ,
173+ contentUrl ,
160174 assetBundlesUrl ) ;
161175
162176 AddWearablesToCatalog ( wearables ) ;
@@ -582,5 +596,8 @@ private bool IsInvalidWearable(EntityDto.MetadataDto metadata)
582596
583597 return false ;
584598 }
599+
600+ private bool IsLocalPreview ( ) =>
601+ dataStore . realm . playerRealm . Get ( ) ? . serverName ? . Equals ( "LocalPreview" , StringComparison . OrdinalIgnoreCase ) ?? false ;
585602 }
586603}
0 commit comments