diff options
author | Reto Brunner <reto@labrat.space> | 2020-05-27 07:52:13 +0200 |
---|---|---|
committer | Reto Brunner <reto@labrat.space> | 2020-05-27 08:11:40 +0200 |
commit | f06d683688e3d2139b14f67b7e349089e7200bf4 (patch) | |
tree | eee331112cbcfeafdb8cd6ba126d9e51ed72b10a /widgets | |
parent | 0f78f06610c0e8887aba2ae50e99b86477a384b3 (diff) | |
download | aerc-f06d683688e3d2139b14f67b7e349089e7200bf4.tar.gz |
Remove duration from the status methods
We always set 10 seconds anyhow, might as well do that without repeating ourselfs.
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/account-wizard.go | 7 | ||||
-rw-r--r-- | widgets/account.go | 3 | ||||
-rw-r--r-- | widgets/aerc.go | 20 | ||||
-rw-r--r-- | widgets/compose.go | 5 | ||||
-rw-r--r-- | widgets/msglist.go | 3 | ||||
-rw-r--r-- | widgets/tabhost.go | 10 |
6 files changed, 20 insertions, 28 deletions
diff --git a/widgets/account-wizard.go b/widgets/account-wizard.go index e247dd23..9bdac982 100644 --- a/widgets/account-wizard.go +++ b/widgets/account-wizard.go @@ -10,7 +10,6 @@ import ( "path" "strconv" "strings" - "time" "github.com/gdamore/tcell" "github.com/go-ini/ini" @@ -429,7 +428,7 @@ func (wizard *AccountWizard) ConfigureTemporaryAccount(temporary bool) { func (wizard *AccountWizard) errorFor(d ui.Interactive, err error) { if d == nil { - wizard.aerc.PushError(" "+err.Error(), 10*time.Second) + wizard.aerc.PushError(" " + err.Error()) wizard.Invalidate() return } @@ -444,7 +443,7 @@ func (wizard *AccountWizard) errorFor(d ui.Interactive, err error) { wizard.step = step wizard.focus = focus wizard.Focus(true) - wizard.aerc.PushError(" "+err.Error(), 10*time.Second) + wizard.aerc.PushError(" " + err.Error()) wizard.Invalidate() return } @@ -555,7 +554,7 @@ func (wizard *AccountWizard) finish(tutorial bool) { term.OnClose = func(err error) { wizard.aerc.RemoveTab(term) if err != nil { - wizard.aerc.PushError(" "+err.Error(), 10*time.Second) + wizard.aerc.PushError(" " + err.Error()) } } } diff --git a/widgets/account.go b/widgets/account.go index 564a95d1..113cbf78 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "log" - "time" "github.com/gdamore/tcell" @@ -290,7 +289,7 @@ func (acct *AccountView) getSortCriteria() []*types.SortCriterion { } criteria, err := sort.GetSortCriteria(acct.UiConfig().Sort) if err != nil { - acct.aerc.PushError(" ui.sort: "+err.Error(), 10*time.Second) + acct.aerc.PushError(" ui.sort: " + err.Error()) return nil } return criteria diff --git a/widgets/aerc.go b/widgets/aerc.go index 57d6cef9..47d7cc29 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -386,16 +386,16 @@ func (aerc *Aerc) SetError(status string) *StatusMessage { return aerc.statusline.SetError(status) } -func (aerc *Aerc) PushStatus(text string, expiry time.Duration) *StatusMessage { - return aerc.statusline.Push(text, expiry) +func (aerc *Aerc) PushStatus(text string) *StatusMessage { + return aerc.statusline.Push(text, 10*time.Second) } -func (aerc *Aerc) PushError(text string, expiry time.Duration) *StatusMessage { - return aerc.statusline.PushError(text, expiry) +func (aerc *Aerc) PushError(text string) *StatusMessage { + return aerc.statusline.PushError(text, 10*time.Second) } -func (aerc *Aerc) PushSuccess(text string, expiry time.Duration) *StatusMessage { - return aerc.statusline.PushSuccess(text, expiry) +func (aerc *Aerc) PushSuccess(text string) *StatusMessage { + return aerc.statusline.PushSuccess(text, 10*time.Second) } func (aerc *Aerc) focus(item ui.Interactive) { @@ -424,11 +424,11 @@ func (aerc *Aerc) BeginExCommand(cmd string) { exline := NewExLine(aerc.conf, cmd, func(cmd string) { parts, err := shlex.Split(cmd) if err != nil { - aerc.PushError(" "+err.Error(), 10*time.Second) + aerc.PushError(" " + err.Error()) } err = aerc.cmd(parts) if err != nil { - aerc.PushError(" "+err.Error(), 10*time.Second) + aerc.PushError(" " + err.Error()) } // only add to history if this is an unsimulated command, // ie one not executed from a keybinding @@ -452,7 +452,7 @@ func (aerc *Aerc) RegisterPrompt(prompt string, cmd []string) { } err := aerc.cmd(cmd) if err != nil { - aerc.PushError(" "+err.Error(), 10*time.Second) + aerc.PushError(" " + err.Error()) } }, func(cmd string) []string { return nil // TODO: completions @@ -479,7 +479,7 @@ func (aerc *Aerc) RegisterChoices(choices []Choice) { } err := aerc.cmd(cmd) if err != nil { - aerc.PushError(" "+err.Error(), 10*time.Second) + aerc.PushError(" " + err.Error()) } }, func(cmd string) []string { return nil // TODO: completions diff --git a/widgets/compose.go b/widgets/compose.go index f85e1f34..a0faf588 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -73,7 +73,7 @@ func NewComposer(aerc *Aerc, acct *AccountView, conf *config.AercConfig, templateData := templates.ParseTemplateData(defaults, original) cmpl := completer.New(conf.Compose.AddressBookCmd, func(err error) { aerc.PushError( - fmt.Sprintf("could not complete header: %v", err), 10*time.Second) + fmt.Sprintf("could not complete header: %v", err)) worker.Logger.Printf("could not complete header: %v", err) }, aerc.Logger()) layout, editors, focusable := buildComposeHeader(aerc, cmpl, defaults) @@ -261,8 +261,7 @@ func (c *Composer) readSignatureFromFile() []byte { signature, err := ioutil.ReadFile(sigFile) if err != nil { c.aerc.PushError( - fmt.Sprintf(" Error loading signature from file: %v", sigFile), - 10*time.Second) + fmt.Sprintf(" Error loading signature from file: %v", sigFile)) return nil } return signature diff --git a/widgets/msglist.go b/widgets/msglist.go index 5d12f8e3..b440f3e0 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -3,7 +3,6 @@ package widgets import ( "fmt" "log" - "time" "github.com/gdamore/tcell" "github.com/mattn/go-runewidth" @@ -186,7 +185,7 @@ func (ml *MessageList) MouseEvent(localX int, localY int, event tcell.Event) { lib.NewMessageStoreView(msg, store, ml.aerc.DecryptKeys, func(view lib.MessageView, err error) { if err != nil { - ml.aerc.PushError(err.Error(), 10*time.Second) + ml.aerc.PushError(err.Error()) return } viewer := NewMessageViewer(acct, ml.aerc.Config(), view) diff --git a/widgets/tabhost.go b/widgets/tabhost.go index 1322a0aa..b6b3041d 100644 --- a/widgets/tabhost.go +++ b/widgets/tabhost.go @@ -1,15 +1,11 @@ package widgets -import ( - "time" -) - type TabHost interface { BeginExCommand(cmd string) SetStatus(status string) *StatusMessage SetError(err string) *StatusMessage - PushStatus(text string, expiry time.Duration) *StatusMessage - PushError(text string, expiry time.Duration) *StatusMessage - PushSuccess(text string, expiry time.Duration) *StatusMessage + PushStatus(text string) *StatusMessage + PushError(text string) *StatusMessage + PushSuccess(text string) *StatusMessage Beep() } |