mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-25 22:32:13 +02:00
Add methods for converting RefresherConfig times to time.Durations
This commit is contained in:
@@ -49,6 +49,14 @@ type RefresherConfig struct {
|
|||||||
FetchInterval int `yaml:"fetchInterval" jsonschema:"minimum=0"`
|
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 {
|
type GuiConfig struct {
|
||||||
// See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#custom-author-color
|
// See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#custom-author-color
|
||||||
AuthorColors map[string]string `yaml:"authorColors"`
|
AuthorColors map[string]string `yaml:"authorColors"`
|
||||||
|
|||||||
@@ -89,14 +89,14 @@ func (self *BackgroundRoutineMgr) startBackgroundFetch() {
|
|||||||
_ = fetch()
|
_ = fetch()
|
||||||
|
|
||||||
userConfig := self.gui.UserConfig()
|
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() {
|
func (self *BackgroundRoutineMgr) startBackgroundFilesRefresh() {
|
||||||
self.gui.waitForIntro.Wait()
|
self.gui.waitForIntro.Wait()
|
||||||
|
|
||||||
userConfig := self.gui.UserConfig()
|
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}})
|
self.gui.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.FILES}})
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user