mirror of
https://github.com/issadarkthing/gomu.git
synced 2025-05-10 19:29:19 +08:00
make fetching search result non-blocking
This commit is contained in:
parent
83ce3894bb
commit
2099a144e2
21
command.go
21
command.go
@ -91,14 +91,18 @@ func (c Command) defineCommands() {
|
||||
switch key {
|
||||
case tcell.KeyEnter:
|
||||
search := input.GetText()
|
||||
defaultTimedPopup(" Youtube Search ", "Searching for "+search)
|
||||
gomu.pages.RemovePage(popupId)
|
||||
gomu.popups.pop()
|
||||
|
||||
results, err := getSearchResult(search)
|
||||
if err != nil {
|
||||
logError(err)
|
||||
defaultTimedPopup(" Error ", err.Error())
|
||||
} else {
|
||||
go func() {
|
||||
|
||||
results, err := getSearchResult(search)
|
||||
if err != nil {
|
||||
logError(err)
|
||||
defaultTimedPopup(" Error ", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
titles := []string{}
|
||||
urls := make(map[string]string)
|
||||
@ -119,7 +123,6 @@ func (c Command) defineCommands() {
|
||||
}
|
||||
|
||||
searchPopup(titles, func(title string) {
|
||||
defaultTimedPopup(" URL ", title)
|
||||
|
||||
audioFile := gomu.playlist.getCurrentFile()
|
||||
|
||||
@ -140,15 +143,15 @@ func (c Command) defineCommands() {
|
||||
}()
|
||||
gomu.app.SetFocus(gomu.prevPanel.(tview.Primitive))
|
||||
})
|
||||
}
|
||||
|
||||
gomu.app.Draw()
|
||||
}()
|
||||
|
||||
case tcell.KeyEscape:
|
||||
gomu.pages.RemovePage(popupId)
|
||||
gomu.popups.pop()
|
||||
gomu.app.SetFocus(gomu.prevPanel.(tview.Primitive))
|
||||
|
||||
case tcell.KeyBackspace:
|
||||
|
||||
default:
|
||||
input.Autocomplete()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user