diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/msgstore.go | 15 | ||||
-rw-r--r-- | lib/ui/interfaces.go | 9 | ||||
-rw-r--r-- | lib/ui/ui.go | 3 |
3 files changed, 23 insertions, 4 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go index 48a105e..b346129 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -33,12 +33,14 @@ type MessageStore struct { pendingHeaders map[uint32]interface{} worker *types.Worker - triggerNewEmail func(*models.MessageInfo) + triggerNewEmail func(*models.MessageInfo) + triggerDirectoryChange func() } func NewMessageStore(worker *types.Worker, dirInfo *models.DirectoryInfo, - triggerNewEmail func(*models.MessageInfo)) *MessageStore { + triggerNewEmail func(*models.MessageInfo), + triggerDirectoryChange func()) *MessageStore { return &MessageStore{ Deleted: make(map[uint32]interface{}), @@ -52,7 +54,8 @@ func NewMessageStore(worker *types.Worker, pendingHeaders: make(map[uint32]interface{}), worker: worker, - triggerNewEmail: triggerNewEmail, + triggerNewEmail: triggerNewEmail, + triggerDirectoryChange: triggerDirectoryChange, } } @@ -147,6 +150,7 @@ func merge(to *models.MessageInfo, from *models.MessageInfo) { func (store *MessageStore) Update(msg types.WorkerMessage) { update := false + directoryChange := false switch msg := msg.(type) { case *types.DirectoryInfo: store.DirInfo = *msg.Info @@ -159,6 +163,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) { newMap[uid] = msg } else { newMap[uid] = nil + directoryChange = true } } store.Messages = newMap @@ -225,6 +230,10 @@ func (store *MessageStore) Update(msg types.WorkerMessage) { if update { store.update() } + + if directoryChange && store.triggerDirectoryChange != nil { + store.triggerDirectoryChange() + } } func (store *MessageStore) OnUpdate(fn func(store *MessageStore)) { diff --git a/lib/ui/interfaces.go b/lib/ui/interfaces.go index 9008ea7..2f63424 100644 --- a/lib/ui/interfaces.go +++ b/lib/ui/interfaces.go @@ -23,6 +23,10 @@ type Interactive interface { Focus(focus bool) } +type Beeper interface { + OnBeep(func() error) +} + type Simulator interface { // Queues up the given input events for simulation Simulate(events []tcell.Event) @@ -33,6 +37,11 @@ type DrawableInteractive interface { Interactive } +type DrawableInteractiveBeeper interface { + DrawableInteractive + Beeper +} + // A drawable which contains other drawables type Container interface { Drawable diff --git a/lib/ui/ui.go b/lib/ui/ui.go index 13b640b..4c3dd34 100644 --- a/lib/ui/ui.go +++ b/lib/ui/ui.go @@ -19,7 +19,7 @@ type UI struct { } func Initialize(conf *config.AercConfig, - content DrawableInteractive) (*UI, error) { + content DrawableInteractiveBeeper) (*UI, error) { screen, err := tcell.NewScreen() if err != nil { @@ -57,6 +57,7 @@ func Initialize(conf *config.AercConfig, content.OnInvalidate(func(_ Drawable) { atomic.StoreInt32(&state.invalid, 1) }) + content.OnBeep(screen.Beep) content.Focus(true) return &state, nil |