From d45f27b6ee9c7b8fe9f77e6c1722fc9109ebd798 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 16 Nov 2025 13:12:14 +0100 Subject: [PATCH] Add methods for converting RefresherConfig times to time.Durations --- pkg/config/user_config.go | 8 ++++++++ pkg/gui/background.go | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 324e425fd..582d98f78 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -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"` diff --git a/pkg/gui/background.go b/pkg/gui/background.go index 362c23c6f..9d034ffa1 100644 --- a/pkg/gui/background.go +++ b/pkg/gui/background.go @@ -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 })