mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-21 12:16:54 +02:00
refactor repeater functions and refresh file panel every ten seconds
This commit is contained in:
parent
58977ed7f3
commit
a56643fe64
29
gui.go
29
gui.go
@ -216,12 +216,13 @@ func layout(g *gocui.Gui) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetch(g *gocui.Gui) {
|
func fetch(g *gocui.Gui) error {
|
||||||
gitFetch()
|
gitFetch()
|
||||||
refreshStatus(g)
|
refreshStatus(g)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateLoader(g *gocui.Gui) {
|
func updateLoader(g *gocui.Gui) error {
|
||||||
if confirmationView, _ := g.View("confirmation"); confirmationView != nil {
|
if confirmationView, _ := g.View("confirmation"); confirmationView != nil {
|
||||||
content := trimmedContent(confirmationView)
|
content := trimmedContent(confirmationView)
|
||||||
if strings.Contains(content, "...") {
|
if strings.Contains(content, "...") {
|
||||||
@ -229,6 +230,15 @@ func updateLoader(g *gocui.Gui) {
|
|||||||
renderString(g, "confirmation", staticContent+" "+loader())
|
renderString(g, "confirmation", staticContent+" "+loader())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func goEvery(g *gocui.Gui, interval time.Duration, function func(*gocui.Gui) error) {
|
||||||
|
go func() {
|
||||||
|
for range time.Tick(interval) {
|
||||||
|
function(g)
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func run() (err error) {
|
func run() (err error) {
|
||||||
@ -238,18 +248,9 @@ func run() (err error) {
|
|||||||
}
|
}
|
||||||
defer g.Close()
|
defer g.Close()
|
||||||
|
|
||||||
// periodically fetching to check for upstream differences
|
goEvery(g, time.Second*60, fetch)
|
||||||
go func() {
|
goEvery(g, time.Second*10, refreshFiles)
|
||||||
for range time.Tick(time.Second * 60) {
|
goEvery(g, time.Millisecond*10, updateLoader)
|
||||||
fetch(g)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
for range time.Tick(time.Millisecond * 10) {
|
|
||||||
updateLoader(g)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
g.SetManagerFunc(layout)
|
g.SetManagerFunc(layout)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user