commit a8b2732728d7999b350dce65cf4924ed781be727
parent 3fbcf857e25b2900a296880ea1e84e2caeaf5636
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date: Wed, 9 Jun 2010 18:40:33 -0700
Merge branch 'master' into next
Conflicts:
lib/sup/modes/thread-index-mode.rb
Diffstat:
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -231,7 +231,7 @@ EOS
old_cursor_thread = cursor_thread
@mutex.synchronize do
## let's see you do THIS in python
- @threads = @ts.threads.select { |t| !@hidden_threads[t] }.select(&:first).sort_by { |t| [t.date, t.first.id] }.reverse
+ @threads = @ts.threads.select { |t| !@hidden_threads.member?(t) }.sort_by(&:sort_key)
@size_widgets = @threads.map { |t| size_widget_for_thread t }
@size_widget_width = @size_widgets.max_of { |w| w.display_length }
@date_widgets = @threads.map { |t| date_widget_for_thread t }
diff --git a/lib/sup/thread.rb b/lib/sup/thread.rb
@@ -146,6 +146,11 @@ class Thread
def to_s
"<thread containing: #{@containers.join ', '}>"
end
+
+ def sort_key
+ m = latest_message
+ m ? [-m.date.to_i, m.id] : [-Time.now.to_i, ""]
+ end
end
## recursive structure used internally to represent message trees as