1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-23 22:24:51 +02:00

Add methods for converting RefresherConfig times to time.Durations

This commit is contained in:
Stefan Haller
2025-11-16 13:12:14 +01:00
parent 472b964da3
commit d45f27b6ee
2 changed files with 10 additions and 2 deletions

View File

@@ -49,6 +49,14 @@ type RefresherConfig struct {
FetchInterval int `yaml:"fetchInterval" jsonschema:"minimum=0"`
}
func (c *RefresherConfig) RefreshIntervalDuration() time.Duration {
return time.Second * time.Duration(c.RefreshInterval)
}
func (c *RefresherConfig) FetchIntervalDuration() time.Duration {
return time.Second * time.Duration(c.FetchInterval)
}
type GuiConfig struct {
// See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#custom-author-color
AuthorColors map[string]string `yaml:"authorColors"`

View File

@@ -89,14 +89,14 @@ func (self *BackgroundRoutineMgr) startBackgroundFetch() {
_ = fetch()
userConfig := self.gui.UserConfig()
self.triggerFetch = self.goEvery(time.Second*time.Duration(userConfig.Refresher.FetchInterval), self.gui.stopChan, fetch)
self.triggerFetch = self.goEvery(userConfig.Refresher.FetchIntervalDuration(), self.gui.stopChan, fetch)
}
func (self *BackgroundRoutineMgr) startBackgroundFilesRefresh() {
self.gui.waitForIntro.Wait()
userConfig := self.gui.UserConfig()
self.goEvery(time.Second*time.Duration(userConfig.Refresher.RefreshInterval), self.gui.stopChan, func() error {
self.goEvery(userConfig.Refresher.RefreshIntervalDuration(), self.gui.stopChan, func() error {
self.gui.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.FILES}})
return nil
})