sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 9a0188e4299b904e28a412e804e59a318835d7eb
parent 18762fa0319c3fdc2eacbe8c043bcd6f7ad668a2
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Sat,  2 Feb 2008 20:19:25 -0800

Merge branches 'dispatch-next-fix', 'handle-deletion-fix' and 'handle-spam-fix' into next

Diffstat:
M lib/sup/modes/thread-index-mode.rb | 22 ++++++++++++++++------
M lib/sup/modes/thread-view-mode.rb | 4 ++--
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -123,9 +123,13 @@ EOS
         set_cursor_pos l + 1 # move out of mutex?
         @threads[l + 1]
       end
-    end or return
+    end
 
-    select t, b
+    if t # there's a next thread
+      select t, b
+    elsif b # no next thread. call the block anyways
+      b.call
+    end
   end
   
   def handle_single_message_labeled_update sender, m
@@ -172,10 +176,16 @@ EOS
   end
 
   def handle_deleted_update sender, m
-    @ts_mutex.synchronize do
-      return unless @ts.contains? m
-      @ts.remove_thread_containing_id m.id
-    end
+    t = @ts_mutex.synchronize { @ts.thread_for m }
+    return unless t
+    hide_thread t
+    update
+  end
+
+  def handle_spammed_update sender, m
+    t = @ts_mutex.synchronize { @ts.thread_for m }
+    return unless t
+    hide_thread t
     update
   end
 
diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
@@ -422,11 +422,11 @@ EOS
     case op
     when :next
       @index_mode.launch_next_thread_after(@thread) do
-        @thread.save Index if block_given? && yield
+        yield if block_given?
         BufferManager.kill_buffer_safely buffer
       end
     when :kill
-      @thread.save Index if yield
+      yield if block_given?
       BufferManager.kill_buffer_safely buffer
     else
       raise ArgumentError, "unknown thread dispatch operation #{op.inspect}"