mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-20 05:19:24 +02:00
Extract a SaveAppStateAndLogError function
It seems that most actions that change a state option and resave the state want to just log the error.
This commit is contained in:
parent
1dac4158e9
commit
1106981827
@ -24,9 +24,7 @@ func (self *ToggleWhitespaceAction) Call() error {
|
||||
}
|
||||
|
||||
self.c.GetAppState().IgnoreWhitespaceInDiffView = !self.c.GetAppState().IgnoreWhitespaceInDiffView
|
||||
if err := self.c.SaveAppState(); err != nil {
|
||||
self.c.Log.Errorf("error when saving app state: %v", err)
|
||||
}
|
||||
self.c.SaveAppStateAndLogError()
|
||||
|
||||
return self.c.CurrentSideContext().HandleFocus(types.OnFocusOpts{})
|
||||
}
|
||||
|
@ -24,9 +24,7 @@ func (gui *Gui) handleCreateExtrasMenuPanel() error {
|
||||
show := !gui.c.State().GetShowExtrasWindow()
|
||||
gui.c.State().SetShowExtrasWindow(show)
|
||||
gui.c.GetAppState().HideCommandLog = !show
|
||||
if err := gui.c.SaveAppState(); err != nil {
|
||||
gui.c.Log.Errorf("error when saving app state: %v", err)
|
||||
}
|
||||
gui.c.SaveAppStateAndLogError()
|
||||
return nil
|
||||
},
|
||||
},
|
||||
|
@ -92,6 +92,12 @@ func (self *guiCommon) SaveAppState() error {
|
||||
return self.gui.Config.SaveAppState()
|
||||
}
|
||||
|
||||
func (self *guiCommon) SaveAppStateAndLogError() {
|
||||
if err := self.gui.Config.SaveAppState(); err != nil {
|
||||
self.gui.Log.Errorf("error when saving app state: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *guiCommon) GetConfig() config.AppConfigurer {
|
||||
return self.gui.Config
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ type IGuiCommon interface {
|
||||
GetConfig() config.AppConfigurer
|
||||
GetAppState() *config.AppState
|
||||
SaveAppState() error
|
||||
SaveAppStateAndLogError()
|
||||
|
||||
// Runs the given function on the UI thread (this is for things like showing a popup asking a user for input).
|
||||
// Only necessary to call if you're not already on the UI thread i.e. you're inside a goroutine.
|
||||
|
Loading…
x
Reference in New Issue
Block a user