@@ -384,7 +384,7 @@ export function sortExtensionVersions(versions: IRawGalleryExtensionVersion[], p
384
384
return versions ;
385
385
}
386
386
387
- function toExtension ( galleryExtension : IRawGalleryExtension , version : IRawGalleryExtensionVersion , allTargetPlatforms : TargetPlatform [ ] , telemetryData ?: any ) : IGalleryExtension {
387
+ function toExtension ( galleryExtension : IRawGalleryExtension , version : IRawGalleryExtensionVersion , allTargetPlatforms : TargetPlatform [ ] , hasReleaseVersion : boolean , telemetryData ?: IStringDictionary < any > ) : IGalleryExtension {
388
388
const latestVersion = galleryExtension . versions [ 0 ] ;
389
389
const assets = < IGalleryExtensionAssets > {
390
390
manifest : getVersionAsset ( version , AssetType . Manifest ) ,
@@ -428,6 +428,7 @@ function toExtension(galleryExtension: IRawGalleryExtension, version: IRawGaller
428
428
isPreReleaseVersion : isPreReleaseVersion ( version )
429
429
} ,
430
430
hasPreReleaseVersion : isPreReleaseVersion ( latestVersion ) ,
431
+ hasReleaseVersion,
431
432
preview : getIsPreview ( galleryExtension . flags ) ,
432
433
/* __GDPR__FRAGMENT__
433
434
"GalleryExtensionTelemetryData2" : {
@@ -543,7 +544,8 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
543
544
} ;
544
545
}
545
546
if ( await this . isRawExtensionVersionCompatible ( rawVersion , includePreRelease , allTargetPlatforms , targetPlatform ) ) {
546
- return toExtension ( rawExtension , rawVersion , allTargetPlatforms ) ;
547
+ const hasReleaseVersion = rawExtension . versions . some ( version => ! isPreReleaseVersion ( version ) ) ;
548
+ return toExtension ( rawExtension , rawVersion , allTargetPlatforms , hasReleaseVersion ) ;
547
549
}
548
550
}
549
551
@@ -654,28 +656,29 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
654
656
return { firstPage : extensions , total, pageSize : query . pageSize , getPage } as IPager < IGalleryExtension > ;
655
657
}
656
658
657
- private async converToGalleryExtensions ( rawGalleryExtensions : { rawGalleryExtension : IRawGalleryExtension , version ?: string } [ ] , includePreRelease : boolean , targetPlatform : TargetPlatform , telemetryData : ( index : number ) => any , token : CancellationToken ) : Promise < IGalleryExtension [ ] > {
658
- const toExtensionWithLatestVersion = ( galleryExtension : IRawGalleryExtension , index : number ) : IGalleryExtension => {
659
+ private async converToGalleryExtensions ( rawGalleryExtensions : { rawGalleryExtension : IRawGalleryExtension , version ?: string } [ ] , includePreRelease : boolean , targetPlatform : TargetPlatform , telemetryData : ( index : number ) => IStringDictionary < any > | undefined , token : CancellationToken ) : Promise < IGalleryExtension [ ] > {
660
+ const toExtensionWithLatestVersion = ( galleryExtension : IRawGalleryExtension , index : number , hasReleaseVersion : boolean ) : IGalleryExtension => {
659
661
const allTargetPlatforms = getAllTargetPlatforms ( galleryExtension ) ;
660
662
let latestVersion = galleryExtension . versions [ 0 ] ;
661
663
latestVersion = galleryExtension . versions . find ( version => version . version === latestVersion . version && isTargetPlatformCompatible ( getTargetPlatformForExtensionVersion ( version ) , allTargetPlatforms , targetPlatform ) ) || latestVersion ;
662
- if ( ! includePreRelease && isPreReleaseVersion ( latestVersion ) ) {
664
+ if ( isPreReleaseVersion ( latestVersion ) && ! includePreRelease ) {
663
665
latestVersion = galleryExtension . versions . find ( version => version . version !== latestVersion . version && ! isPreReleaseVersion ( version ) ) || latestVersion ;
664
666
}
665
- return toExtension ( galleryExtension , latestVersion , allTargetPlatforms , telemetryData ( index ) ) ;
667
+ return toExtension ( galleryExtension , latestVersion , allTargetPlatforms , hasReleaseVersion , telemetryData ( index ) ) ;
666
668
} ;
667
669
const result : [ number , IGalleryExtension ] [ ] = [ ] ;
668
670
const preReleaseVersions = new Map < string , number > ( ) ;
669
671
for ( let index = 0 ; index < rawGalleryExtensions . length ; index ++ ) {
670
672
const { rawGalleryExtension, version } = rawGalleryExtensions [ index ] ;
673
+ const hasReleaseVersion = rawGalleryExtension . versions . some ( version => ! isPreReleaseVersion ( version ) ) ;
671
674
if ( version ) {
672
675
const versionAsset = rawGalleryExtension . versions . find ( v => v . version === version ) ;
673
676
if ( versionAsset ) {
674
- result . push ( [ index , toExtension ( rawGalleryExtension , versionAsset , getAllTargetPlatforms ( rawGalleryExtension ) ) ] ) ;
677
+ result . push ( [ index , toExtension ( rawGalleryExtension , versionAsset , getAllTargetPlatforms ( rawGalleryExtension ) , hasReleaseVersion ) ] ) ;
675
678
}
676
679
} else {
677
- const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index ) ;
678
- if ( extension . properties . isPreReleaseVersion && ! includePreRelease ) {
680
+ const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index , hasReleaseVersion ) ;
681
+ if ( extension . properties . isPreReleaseVersion ) {
679
682
preReleaseVersions . set ( extension . identifier . uuid , index ) ;
680
683
} else {
681
684
result . push ( [ index , extension ] ) ;
@@ -694,8 +697,9 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
694
697
throw new Error ( 'Not all extensions with latest versions are returned' ) ;
695
698
}
696
699
for ( const rawGalleryExtension of galleryExtensions ) {
700
+ const hasReleaseVersion = rawGalleryExtension . versions . some ( version => ! isPreReleaseVersion ( version ) ) ;
697
701
const index = preReleaseVersions . get ( rawGalleryExtension . extensionId ) ! ;
698
- const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index ) ;
702
+ const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index , hasReleaseVersion ) ;
699
703
result . push ( [ index , extension ] ) ;
700
704
}
701
705
}
0 commit comments