Skip to content

Commit

Permalink
Updated to use isCachedLatestVersion and getCachedThunderstoreModFromMod
Browse files Browse the repository at this point in the history
  • Loading branch information
ebkr committed Feb 11, 2024
1 parent 71d1c7c commit 6901227
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/r2mm/downloading/BetterThunderstoreDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,16 @@ export default class BetterThunderstoreDownloader extends ThunderstoreDownloader
}

public getLatestOfAllToUpdate(mods: ManifestV2[], allMods: ThunderstoreMod[]): ThunderstoreCombo[] {

const latestVersionMap = ThunderstorePackages.LATEST_VERSIONS;

return mods.filter(value => {
if (latestVersionMap.has(value.getName())) {
const latestVersion = latestVersionMap.get(value.getName())!;
return latestVersion.getVersionNumber().isNewerThan(value.getVersionNumber());
}
return false;
})
.map(value => {
const combo = new ThunderstoreCombo()
combo.setMod(ModBridge.getThunderstoreModFromMod(value, allMods)!)
combo.setVersion(latestVersionMap.get(value.getName())!);
return mods.filter(mod => !ModBridge.isCachedLatestVersion(mod))
.map(mod => ModBridge.getCachedThunderstoreModFromMod(mod))
.filter(value => value != undefined)
.map(mod => {
const latestVersion = mod!.getVersions().sort((a, b) => a.getVersionNumber().compareToDescending(b.getVersionNumber()))[0];
const combo = new ThunderstoreCombo();
combo.setMod(mod!);
combo.setVersion(latestVersion);
return combo;
});
})
}

public async downloadLatestOfAll(game: Game, mods: ManifestV2[], allMods: ThunderstoreMod[],
Expand Down

0 comments on commit 6901227

Please sign in to comment.