File tree Expand file tree Collapse file tree 3 files changed +14
-8
lines changed
Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ export async function getProjectDescriptor(id: string): Promise<ProjectDescripto
4848 // Check for stable builds
4949 for ( let i = flattenedVersions . length - 1 ; i >= 0 ; i -- ) {
5050 try {
51- const builds = await getVersionBuilds ( id , flattenedVersions [ i ] ) ;
52- if ( builds . some ( ( build ) => build . channel === "STABLE" ) ) {
51+ const builds = await getVersionBuilds ( id , flattenedVersions [ i ] , "STABLE" ) ;
52+ if ( builds . length > 0 ) {
5353 latestStableVersion = flattenedVersions [ i ] ;
5454 break ;
5555 }
@@ -84,8 +84,8 @@ export async function getProjectDescriptorWithHangar(id: string): Promise<{ proj
8484 // Check for stable builds
8585 for ( let i = flattenedVersions . length - 1 ; i >= 0 ; i -- ) {
8686 try {
87- const builds = await getVersionBuilds ( id , flattenedVersions [ i ] ) ;
88- if ( builds . some ( ( build ) => build . channel === "STABLE" ) ) {
87+ const builds = await getVersionBuilds ( id , flattenedVersions [ i ] , "STABLE" ) ;
88+ if ( builds . length > 0 ) {
8989 latestStableVersion = flattenedVersions [ i ] ;
9090 break ;
9191 }
Original file line number Diff line number Diff line change 1- import type { Build , Project } from "@/utils/types" ;
1+ import type { Build , BuildChannel , Project } from "@/utils/types" ;
22
33const API_ENDPOINT = "https://fill.papermc.io/v3" ;
44const BSTATS_URL = "https://bstats.org/api/v1/plugins/580/charts/players/data/?maxElements=1" ;
@@ -20,8 +20,12 @@ export async function getProject(project: string): Promise<Project> {
2020 return res . json ( ) as Promise < Project > ;
2121}
2222
23- export async function getVersionBuilds ( project : string , version : string ) : Promise < Build [ ] > {
24- const res = await edgeFetch ( `${ API_ENDPOINT } /projects/${ project } /versions/${ version } /builds` , 300 ) ;
23+ export async function getVersionBuilds ( project : string , version : string , channel ?: BuildChannel ) : Promise < Build [ ] > {
24+ let url = `${ API_ENDPOINT } /projects/${ project } /versions/${ version } /builds` ;
25+ if ( channel ) {
26+ url += `?channel=${ encodeURIComponent ( channel ) } ` ;
27+ }
28+ const res = await edgeFetch ( url , 300 ) ;
2529 if ( ! res . ok ) {
2630 throw new Error ( `getVersionBuilds(${ project } , ${ version } ) failed: ${ res . status } ` ) ;
2731 }
Original file line number Diff line number Diff line change @@ -36,10 +36,12 @@ export interface VersionFamilyBuild extends Build {
3636 version : string ;
3737}
3838
39+ export type BuildChannel = "ALPHA" | "BETA" | "STABLE" | "RECOMMENDED" ;
40+
3941export interface Build {
4042 id : number ;
4143 time : string ;
42- channel : "ALPHA" | "BETA" | "STABLE" | "RECOMMENDED" ;
44+ channel : BuildChannel ;
4345 commits : BuildChange [ ] ;
4446 downloads : {
4547 [ key : string ] : BuildDownload ;
You can’t perform that action at this time.
0 commit comments