From: wmorgan Date: Mon, 26 Nov 2007 21:31:40 +0000 (+0000) Subject: thread snippet improvement: display snippet of first unread message, or last snippet... X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=4827b906c19b172c59a6b7024b7f89aae2df1216;p=sup 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 --- diff --git a/lib/sup/thread.rb b/lib/sup/thread.rb index 722ba34..d459303 100644 --- 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