sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 4827b906c19b172c59a6b7024b7f89aae2df1216
parent 0bc4913245635453fea1a43b7d43126d789eacb0
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date:   Mon, 26 Nov 2007 21:31:40 +0000

thread snippet improvement: display snippet of first unread message, or last snippet if that doesn't exist

git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@724 5c8cc53c-5e98-4d25-b20a-d8db53a31250

Diffstat:
M lib/sup/thread.rb | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/sup/thread.rb b/lib/sup/thread.rb
@@ -86,8 +86,12 @@ class Thread
   def dirty?; any? { |m, *o| m && m.dirty? }; end
   def date; map { |m, *o| m.date if m }.compact.max; end
   def snippet
-    last_m, last_stuff = select { |m, *o| m && m.snippet && !m.snippet.empty? }.sort_by { |m, *o| m.date }.last
-    last_m ? last_m.snippet : ""
+    with_snippets = select { |m, *o| m && m.snippet && !m.snippet.empty? }
+    first_unread, * = with_snippets.select { |m, *o| m.has_label?(:unread) }.sort_by { |m, *o| m.date }.first
+    return first_unread.snippet if first_unread
+    last_read, * = with_snippets.sort_by { |m, *o| m.date }.last
+    return last_read.snippet if last_read
+    ""
   end
   def authors; map { |m, *o| m.from if m }.compact.uniq; end