mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-15 22:26:40 +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
|
self.c.GetAppState().IgnoreWhitespaceInDiffView = !self.c.GetAppState().IgnoreWhitespaceInDiffView
|
||||||
if err := self.c.SaveAppState(); err != nil {
|
self.c.SaveAppStateAndLogError()
|
||||||
self.c.Log.Errorf("error when saving app state: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return self.c.CurrentSideContext().HandleFocus(types.OnFocusOpts{})
|
return self.c.CurrentSideContext().HandleFocus(types.OnFocusOpts{})
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,7 @@ func (gui *Gui) handleCreateExtrasMenuPanel() error {
|
|||||||
show := !gui.c.State().GetShowExtrasWindow()
|
show := !gui.c.State().GetShowExtrasWindow()
|
||||||
gui.c.State().SetShowExtrasWindow(show)
|
gui.c.State().SetShowExtrasWindow(show)
|
||||||
gui.c.GetAppState().HideCommandLog = !show
|
gui.c.GetAppState().HideCommandLog = !show
|
||||||
if err := gui.c.SaveAppState(); err != nil {
|
gui.c.SaveAppStateAndLogError()
|
||||||
gui.c.Log.Errorf("error when saving app state: %v", err)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -92,6 +92,12 @@ func (self *guiCommon) SaveAppState() error {
|
|||||||
return self.gui.Config.SaveAppState()
|
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 {
|
func (self *guiCommon) GetConfig() config.AppConfigurer {
|
||||||
return self.gui.Config
|
return self.gui.Config
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ type IGuiCommon interface {
|
|||||||
GetConfig() config.AppConfigurer
|
GetConfig() config.AppConfigurer
|
||||||
GetAppState() *config.AppState
|
GetAppState() *config.AppState
|
||||||
SaveAppState() error
|
SaveAppState() error
|
||||||
|
SaveAppStateAndLogError()
|
||||||
|
|
||||||
// Runs the given function on the UI thread (this is for things like showing a popup asking a user for input).
|
// 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.
|
// 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