Skip to content

Commit

Permalink
update searchdialog for fyne.Do
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Jan 31, 2025
1 parent e042fb8 commit 0a9acee
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions ui/dialogs/searchdialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (sd *SearchDialog) SearchQuery() string {

func (sd *SearchDialog) Show() {
sd.BaseWidget.Show()
go sd.onSearched("")
sd.onSearched("")
}

func (sd *SearchDialog) Refresh() {
Expand Down Expand Up @@ -163,14 +163,18 @@ func (sd *SearchDialog) setResults(results []*mediaprovider.SearchResult) {
func (sd *SearchDialog) onSearched(query string) {
sd.loadingDots.Start()
var results []*mediaprovider.SearchResult
res := sd.OnSearched(query)
if len(res) == 0 {
log.Println("No results matched the query.")
} else {
results = res
}
sd.loadingDots.Stop()
sd.setResults(results)
go func() {
res := sd.OnSearched(query)
if len(res) == 0 {
log.Println("No results matched the query.")
} else {
results = res
}
fyne.Do(func() {
sd.loadingDots.Stop()
sd.setResults(results)
})
}()
}

func (sd *SearchDialog) CreateRenderer() fyne.WidgetRenderer {
Expand Down

0 comments on commit 0a9acee

Please sign in to comment.