From a953e4dbe914def4275a6ddfc16e3046804fe03e Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Tue, 5 Jul 2022 14:48:41 -0500 Subject: threading: refactor reselect logic This patch refactors reselection of a message during certain operations (searching, filtering, clearing, deleting, moving, new message arrival). The addition of server-side filtering for threaded views broke the existing reselection logic. Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- widgets/msglist.go | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'widgets') diff --git a/widgets/msglist.go b/widgets/msglist.go index 9e68f219..e9603cae 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -345,27 +345,7 @@ func (ml *MessageList) storeUpdate(store *lib.MessageStore) { if ml.Store() != store { return } - uids := store.Uids() - - if len(uids) > 0 { - // When new messages come in, advance the cursor accordingly - // Note that this assumes new messages are appended to the top, which - // isn't necessarily true once we implement SORT... ideally we'd look - // for the previously selected UID. - if len(uids) > ml.nmsgs && ml.nmsgs != 0 { - for i := 0; i < len(uids)-ml.nmsgs; i++ { - ml.Store().Next() - } - } - if len(uids) < ml.nmsgs && ml.nmsgs != 0 { - for i := 0; i < ml.nmsgs-len(uids); i++ { - ml.Store().Prev() - } - } - ml.nmsgs = len(uids) - } - - ml.Invalidate() + store.Reselect() } func (ml *MessageList) SetStore(store *lib.MessageStore) { -- cgit