style(gtk): clean up search code slightly
This commit is contained in:
parent
c1e729a0fa
commit
9b55a3f08d
@ -127,19 +127,18 @@ class ModsTab(window: InstanceSettingsWindow) : SettingsTab<Leaflet, InstanceSet
|
||||
VoidFuture(ForkJoinPool.commonPool().submit {
|
||||
val sources: List<ModSource> = when (page) {
|
||||
Page.CURSEFORGE -> {
|
||||
val cf = CurseforgeApi.search(instance.gameVersion, currentSearchString, 0, "Popularity") //TODO allow user to choose sort mode
|
||||
cf.mapNotNull {
|
||||
//TODO allow user to choose sort mode
|
||||
CurseforgeApi.search(instance.gameVersion, currentSearchString, 0, "Popularity").mapNotNull { cf ->
|
||||
if (isCancelled) return@submit
|
||||
val file = it.latestFilesIndexes.firstOrNull { it.gameVersion == instance.gameVersion } //TODO support compatible minor versions
|
||||
val file = cf.latestFilesIndexes.firstOrNull { it.gameVersion == instance.gameVersion } //TODO support compatible minor versions
|
||||
if (file == null) null
|
||||
else CurseforgeModSource(it.id, file.fileId)
|
||||
else CurseforgeModSource(cf.id, file.fileId)
|
||||
}
|
||||
}
|
||||
Page.MODRINTH -> {
|
||||
val mr = ModrinthApi.search(currentSearchString, 0, instance.gameVersion, ModrinthProjectType.mod).hits
|
||||
mr.mapNotNull {
|
||||
ModrinthApi.search(currentSearchString, 0, instance.gameVersion, ModrinthProjectType.mod).hits.mapNotNull { mr ->
|
||||
if (isCancelled) return@submit
|
||||
val file = ModrinthApi.getLatestVersions(it.project_id, instance.gameVersion).best
|
||||
val file = ModrinthApi.getLatestVersions(mr.project_id, instance.gameVersion).best
|
||||
if (file == null) null
|
||||
else ModrinthModSource(file.id)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user