fix(gtk): show search and loading indicator

This commit is contained in:
Johannes Frohnmeyer 2024-10-04 17:46:40 +02:00
parent 45d16f82e8
commit 0176698242
Signed by: Johannes
GPG Key ID: E76429612C2929F4

View File

@ -64,15 +64,9 @@ class ModsTab(window: InstanceSettingsWindow) : SettingsTab<Leaflet, InstanceSet
}
}
})
append(SearchBar().apply {
hexpand = false
showCloseButton = false
searchMode = false
val entry = SearchEntry().apply {
onSearchChanged { updateSearch(text) }
}
child = entry
keyCaptureWidget = entry
append(Entry().apply {
setIconFromIconName(EntryIconPosition.PRIMARY, "edit-find-symbolic")
onChanged { updateSearch(text) }
})
listModel = StringList(arrayOf())
append(Overlay().apply {
@ -104,6 +98,7 @@ class ModsTab(window: InstanceSettingsWindow) : SettingsTab<Leaflet, InstanceSet
listModel.replaceAll(mods.map { it.name }.toTypedArray())
} else {
loadingRevealer.setRunning(searchResult == null || !mds.isComplete(ScanStage.CROSSREFERENCE))
loadingRevealer.pulse()
if (searchResult != null) {
for (mod in searchResult.orEmpty()) {
this@ModsTab.mods[mod.name] = mod
@ -123,7 +118,6 @@ class ModsTab(window: InstanceSettingsWindow) : SettingsTab<Leaflet, InstanceSet
private val search = AsyncRequest({
searchResult = null
loadingRevealer.setRunning(true)
loadingRevealer.pulse()
VoidFuture(ForkJoinPool.commonPool().submit {
val sources: List<ModSource> = when (page) {
Page.CURSEFORGE -> {
@ -157,7 +151,6 @@ class ModsTab(window: InstanceSettingsWindow) : SettingsTab<Leaflet, InstanceSet
updateSearch(currentSearchString)
}
fun updateSearch(search: String): Unit {
descriptionLabel.text = "Searching is currently unsupported"
currentSearchString = search
backgroundTask { this.search.request() }
}