update searchdialog for fyne.Do

This commit is contained in:
Drew Weymouth
2025-02-08 08:35:34 -03:00
parent 2ff3853015
commit f7e5e1e9a4
+13 -9
View File
@@ -101,7 +101,7 @@ func (sd *SearchDialog) SearchQuery() string {
func (sd *SearchDialog) Show() { func (sd *SearchDialog) Show() {
sd.BaseWidget.Show() sd.BaseWidget.Show()
go sd.onSearched("") sd.onSearched("")
} }
func (sd *SearchDialog) Refresh() { func (sd *SearchDialog) Refresh() {
@@ -163,14 +163,18 @@ func (sd *SearchDialog) setResults(results []*mediaprovider.SearchResult) {
func (sd *SearchDialog) onSearched(query string) { func (sd *SearchDialog) onSearched(query string) {
sd.loadingDots.Start() sd.loadingDots.Start()
var results []*mediaprovider.SearchResult var results []*mediaprovider.SearchResult
res := sd.OnSearched(query) go func() {
if len(res) == 0 { res := sd.OnSearched(query)
log.Println("No results matched the query.") if len(res) == 0 {
} else { log.Println("No results matched the query.")
results = res } else {
} results = res
sd.loadingDots.Stop() }
sd.setResults(results) fyne.Do(func() {
sd.loadingDots.Stop()
sd.setResults(results)
})
}()
} }
func (sd *SearchDialog) CreateRenderer() fyne.WidgetRenderer { func (sd *SearchDialog) CreateRenderer() fyne.WidgetRenderer {