lib/sup/thread.rb in sup-0.1 vs lib/sup/thread.rb in sup-0.2

- old
+ new

@@ -52,11 +52,11 @@ f.puts "=== end thread ===" end ## yields each message, its depth, and its parent. the message yield ## parameter can be a Message object, or :fake_root, or nil (no - ## message found but the presence of one induced from other + ## message found but the presence of one deduced from other ## messages). def each fake_root=false adj = 0 root = @containers.find_all { |c| !Message.subj_is_reply?(c) }.argmin { |c| c.date || 0 } @@ -83,11 +83,14 @@ end def first; each { |m, *o| return m if m }; nil; end def dirty?; any? { |m, *o| m && m.dirty? }; end def date; map { |m, *o| m.date if m }.compact.max; end - def snippet; argfind { |m, *o| m && m.snippet }; 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 : "" + end def authors; map { |m, *o| m.from if m }.compact.uniq; end def apply_label t; each { |m, *o| m && m.add_label(t) }; end def remove_label t; each { |m, *o| m && m.remove_label(t) }; end @@ -301,21 +304,22 @@ @index.each_id_by_date opts do |mid, builder| break if size >= num next if contains_id? mid m = builder.call - add_message m - load_thread_for_message m, :load_killed => opts[:load_killed] + load_thread_for_message m, :skip_killed => opts[:skip_killed], :load_deleted => opts[:load_deleted], :load_spam => opts[:load_spam] yield size if block_given? end end ## loads in all messages needed to thread m + ## may do nothing if m's thread is killed def load_thread_for_message m, opts={} - @index.each_message_in_thread_for m, opts.merge({:limit => 100}) do |mid, builder| + good = @index.each_message_in_thread_for m, opts do |mid, builder| next if contains_id? mid add_message builder.call end + add_message m if good end ## merges in a pre-loaded thread def add_thread t raise "duplicate" if @threads.values.member? t