refactor: initialize mainFlex in (*cmd.Application).show
This commit is contained in:
parent
cc5fe0620d
commit
1769fa97e1
2 changed files with 5 additions and 5 deletions
|
|
@ -33,7 +33,7 @@ func (app *Application) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
|
|||
return event
|
||||
}
|
||||
|
||||
func (app *Application) Show(token string) error {
|
||||
func (app *Application) show(token string) error {
|
||||
if token == "" {
|
||||
loginForm := newLoginForm(func(token string, err error) {
|
||||
if err != nil {
|
||||
|
|
@ -41,12 +41,14 @@ func (app *Application) Show(token string) error {
|
|||
return
|
||||
}
|
||||
|
||||
if err := app.Show(token); err != nil {
|
||||
if err := app.show(token); err != nil {
|
||||
slog.Error("failed to show app", "err", err)
|
||||
}
|
||||
})
|
||||
app.SetRoot(loginForm, true)
|
||||
} else {
|
||||
// mainFlex must be initialized before opening a new state.
|
||||
mainFlex = newMainFlex()
|
||||
if err := openState(token); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -58,7 +60,7 @@ func (app *Application) Show(token string) error {
|
|||
}
|
||||
|
||||
func (app *Application) Run(token string) error {
|
||||
if err := app.Show(token); err != nil {
|
||||
if err := app.show(token); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,5 @@ func Run(token string) error {
|
|||
|
||||
// app must be initialized after configuration is loaded
|
||||
app = newApplication()
|
||||
// mainFlex must be initialized before opening a new state.
|
||||
mainFlex = newMainFlex()
|
||||
return app.Run(token)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue