Using QueueUpdateDraw() instead of Draw()

The Draw() function still seems to slow down the App
Hence Using QueueUpdateDraw() this makes it a little faster

The Problem now is that the ProgressBar constantly makes request to mpd
which in turn causes the slow down.
This commit is contained in:
aditya-K2 2022-10-03 15:37:26 +05:30
parent 79841c1b91
commit 06da246c3a
3 changed files with 4 additions and 3 deletions

View File

@ -338,8 +338,9 @@ func main() {
}) })
go func() { go func() {
drawFunc := func() { ui.ProgressFunction() }
for { for {
ui.Ui.App.Draw() ui.Ui.App.QueueUpdateDraw(drawFunc)
time.Sleep(time.Second) time.Sleep(time.Second)
} }
}() }()

View File

@ -25,7 +25,7 @@ type Application struct {
func NewApplication() *Application { func NewApplication() *Application {
pBar := NewProgressBar() pBar := NewProgressBar()
pBar.SetProgressFunc(progressFunction) pBar.SetProgressFunc(ProgressFunction)
expandedView := tview.NewTable() expandedView := tview.NewTable()
Navbar := tview.NewTable() Navbar := tview.NewTable()
searchBar := tview.NewInputField() searchBar := tview.NewInputField()

View File

@ -82,7 +82,7 @@ func (self *ProgressBar) Draw(screen tcell.Screen) {
x, y+2, _width-OFFSET, tview.AlignRight, tcell.ColorWhite) x, y+2, _width-OFFSET, tview.AlignRight, tcell.ColorWhite)
} }
func progressFunction() (string, string, string, float64) { func ProgressFunction() (string, string, string, float64) {
_currentAttributes, err := CONN.CurrentSong() _currentAttributes, err := CONN.CurrentSong()
var song, top, text string var song, top, text string
var percentage float64 var percentage float64