diff options
Diffstat (limited to 'lib/msgstore.go')
-rw-r--r-- | lib/msgstore.go | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go index 33daa9ff..274e42ba 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -718,22 +718,26 @@ func (store *MessageStore) SelectedUid() uint32 { } func (store *MessageStore) Select(uid uint32) { - store.threadsMutex.Lock() - if store.threadCallback != nil { - store.threadCallback = nil + store.selectPriv(uid, false) + if store.onSelect != nil { + store.onSelect(store.Selected()) } - store.threadsMutex.Unlock() - store.selectPriv(uid) } -func (store *MessageStore) selectPriv(uid uint32) { +func (store *MessageStore) selectPriv(uid uint32, lockHeld bool) { + if !lockHeld { + store.threadsMutex.Lock() + } + if store.threadCallback != nil { + store.threadCallback = nil + } + if !lockHeld { + store.threadsMutex.Unlock() + } store.selectedUid = uid if store.marker != nil { store.marker.UpdateVisualMark() } - if store.onSelect != nil { - store.onSelect(store.Selected()) - } } func (store *MessageStore) NextPrev(delta int) { @@ -761,7 +765,7 @@ func (store *MessageStore) NextPrev(delta int) { store.threadsMutex.Lock() store.threadCallback = func() { if uids := store.Uids(); len(uids) > newIdx { - store.selectPriv(uids[newIdx]) + store.selectPriv(uids[newIdx], true) } } store.threadsMutex.Unlock() |