Skip to content

Commit 9313653

Browse files
committed
Use getCombosByDependencyStrings in ProfileUtils
The recently added helper is more suitable for the use case. This also means the implementation doesn't depend on ThunderstoreMod containing references to all related ThunderstoreVersions anymore - a change we want to introduce to reduce the apps memory footprint.
1 parent 71a676b commit 9313653

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

src/model/exports/ExportMod.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ export default class ExportMod {
4343
return this.version;
4444
}
4545

46+
public getDependencyString(): string {
47+
return `${this.name}-${this.version}`;
48+
}
49+
4650
public isEnabled(): boolean {
4751
return this.enabled;
4852
}

src/utils/ProfileUtils.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,8 @@ import * as PackageDb from '../r2mm/manager/PackageDexieStore';
1717
import ProfileModList from "../r2mm/mods/ProfileModList";
1818

1919
export async function exportModsToCombos(exportMods: ExportMod[], community: string): Promise<ThunderstoreCombo[]> {
20-
const tsMods = await PackageDb.getPackagesByNames(community, exportMods.map((m) => m.getName()));
21-
22-
const combos = tsMods.map((tsMod) => {
23-
const targetMod = exportMods.find((expMod) => tsMod.getFullName() == expMod.getName());
24-
const version = targetMod
25-
? tsMod.getVersions().find((ver) => ver.getVersionNumber().isEqualTo(targetMod.getVersionNumber()))
26-
: undefined;
27-
28-
if (version) {
29-
const combo = new ThunderstoreCombo();
30-
combo.setMod(tsMod);
31-
combo.setVersion(version);
32-
return combo;
33-
}
34-
}).filter((combo): combo is ThunderstoreCombo => combo !== undefined);
20+
const dependencyStrings = exportMods.map((m) => m.getDependencyString());
21+
const combos = await PackageDb.getCombosByDependencyStrings(community, dependencyStrings);
3522

3623
if (combos.length === 0) {
3724
throw new R2Error(

0 commit comments

Comments
 (0)