diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-01-11 09:04:18 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-01-11 09:04:18 -0500 |
commit | 4074445cbb45dc6ec132e67b7eac9f32dcfd53de (patch) | |
tree | abb2348df84e12f0a781a4e0d29509962d01c756 /ui/ui.go | |
parent | ffba56133406027a6a740f9f4454b27134143f0a (diff) | |
download | aerc-4074445cbb45dc6ec132e67b7eac9f32dcfd53de.tar.gz |
Move worker into account tab
Diffstat (limited to 'ui/ui.go')
-rw-r--r-- | ui/ui.go | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -11,7 +11,8 @@ func Initialize(conf *config.AercConfig) (*UIState, error) { Config: conf, InvalidPanes: InvalidateAll, - tbEvents: make(chan tb.Event, 10), + tbEvents: make(chan tb.Event, 10), + workerEvents: make(chan wrappedMessage), } if err := tb.Init(); err != nil { return nil, err @@ -33,6 +34,16 @@ func (state *UIState) Close() { func (state *UIState) AddTab(tab AercTab) { tab.SetParent(state) state.Tabs = append(state.Tabs, tab) + if listener, ok := tab.(WorkerListener); ok { + go (func() { + for msg := range listener.GetChannel() { + state.workerEvents <- wrappedMessage{ + msg: msg, + listener: listener, + } + } + })() + } } func (state *UIState) Invalidate(what uint) { @@ -67,6 +78,8 @@ func (state *UIState) Tick() bool { case tb.EventResize: state.Invalidate(InvalidateAll) } + case msg := <-state.workerEvents: + msg.listener.HandleMessage(msg.msg) default: // no-op break |