From ebbb3d89ce5b0f54caddc8c20b0a96f62d0d8079 Mon Sep 17 00:00:00 2001 From: raziman Date: Sun, 2 Aug 2020 16:02:07 +0800 Subject: [PATCH] create gomu.quit() method --- gomu.go | 15 ++++++++++++++- popup.go | 10 ++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/gomu.go b/gomu.go index fbbada4..c9bc91e 100644 --- a/gomu.go +++ b/gomu.go @@ -6,6 +6,7 @@ import ( "github.com/gdamore/tcell" "github.com/rivo/tview" "github.com/spf13/viper" + "github.com/ztrue/tracerr" ) const VERSION = "v1.4.0" @@ -33,7 +34,7 @@ type Gomu struct { func newGomu() *Gomu { gomu := &Gomu{ - popupBg: tcell.GetColor(viper.GetString("color.popup")), + popupBg: tcell.GetColor("#0A0F14"), textColor: tcell.GetColor(viper.GetString("color.foreground")), accentColor: tcell.GetColor(viper.GetString("color.accent")), } @@ -137,3 +138,15 @@ func (g *Gomu) setUnfocusPanel(panel Panel) { g.prevPanel.SetBorderColor(g.textColor) g.prevPanel.SetTitleColor((g.textColor)) } + +// Quit the application and do the neccessary clean up +func (g *Gomu) quit() error { + + if err := gomu.queue.saveQueue(); err != nil { + return tracerr.Wrap(err) + } + + gomu.app.Stop() + + return nil +} diff --git a/popup.go b/popup.go index 9d72e89..6a24893 100644 --- a/popup.go +++ b/popup.go @@ -344,15 +344,9 @@ func exitConfirmation() { return } - if err := gomu.queue.saveQueue(); err != nil { + err := gomu.quit() + if err != nil { logError(err) } - - if err := viper.WriteConfig(); err != nil { - logError(err) - } - - gomu.app.Stop() - }) }