File tree Expand file tree Collapse file tree
QuestAppVersionSwitcher/Assets/html/flows Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -610,13 +610,45 @@ <h2>Upload logs</h2>
610610
611611 function InstallCoreModsAndGetMods ( ) {
612612 UpdateModdedStatus ( ) . then ( res => {
613- fetch ( start + `/api/mods/installfromurl` , {
614- method : "POST" ,
615- body : `https://raw.githubusercontent.com/QuestPackageManager/bs-coremods/main/core_mods.json?${ new Date ( ) . getTime ( ) } `
616- } ) . then ( res => {
613+ fetch ( `https://raw.githubusercontent.com/QuestPackageManager/bs-coremods/main/core_mods.json?${ new Date ( ) . getTime ( ) } ` ) . then ( res => {
614+ if ( ! res . ok ) {
615+ console . error ( `Failed to fetch core mods: ${ res . status } ${ res . statusText } ` ) ;
616+ }
617+ return res . json ( ) ;
618+ } )
619+ . then ( data => {
620+ // Find the mods for the specified version
621+ const versionData = data [ moddedStatus . version ] ;
622+
623+ if ( versionData && versionData . mods ) {
624+ // Extract download links for each mod
625+ const downloadLinks = versionData . mods . map ( mod => mod . downloadLink ) ;
626+ console . log ( `Download links for version ${ moddedStatus . version } :` , downloadLinks ) ;
627+ return downloadLinks ;
628+ } else {
629+ console . log ( `No mods found for version ${ moddedStatus . version } ` ) ;
630+ return [ ] ;
631+ }
632+ } ) . then ( mods => {
633+ // For each mod's download link, perform a POST request
634+ mods . forEach ( url => {
635+ fetch ( start + "/api/mods/installfromurl" , {
636+ method : "POST" ,
637+ body : url
638+ } )
639+ . then ( postRes => {
640+ if ( ! postRes . ok ) {
641+ console . error ( `Failed to post link: ${ postRes . status } ${ postRes . statusText } ` ) ;
642+ } else {
643+ console . log ( `Successfully posted link: ${ url } ` ) ;
644+ }
645+ } )
646+ . catch ( error => console . error ( "Error posting link:" , error ) ) ;
647+ } ) ;
648+ } ) . then ( ( ) => {
617649 localStorage . openMainDefault = true
618650 location = start + "/?tab=mods"
619- } )
651+ } ) ;
620652 } )
621653 }
622654
You can’t perform that action at this time.
0 commit comments