sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit df72056384694a05f0400dbd073e871d7b483f5b
parent 9689d77e242351c6a8a4448172c192e33c238352
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date:   Wed,  9 Jun 2010 18:39:06 -0700

workaround nil Thread#first bug

Diffstat:
M lib/sup/modes/thread-index-mode.rb | 2 +-
M lib/sup/thread.rb | 5 +++++
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] }.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