]> git.cworth.org Git - sup/commitdiff
bugfix: thread correctly in resumed/killed draft messages
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Tue, 8 Jan 2008 18:04:31 +0000 (10:04 -0800)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Tue, 8 Jan 2008 19:45:12 +0000 (11:45 -0800)
the entire thread was being deleted because of UpdateManager changes.
now there are two signals: deleted and single_message_deleted, the first
for thread deletion and the second for draft message removal, and
ThreadIndexMode handles them correctly.

lib/sup/draft.rb
lib/sup/modes/thread-index-mode.rb
lib/sup/thread.rb

index 8d3c4a53f77548b7af11568aeb638de4523a4f49..81c00445f764278ae5e298862c7ca9d567bcce2b 100644 (file)
@@ -36,7 +36,7 @@ class DraftManager
     raise ArgumentError, "not a draft: source id #{entry[:source_id].inspect}, should be #{DraftManager.source_id.inspect} for #{m.id.inspect} / docno #{docid}" unless entry[:source_id].to_i == DraftManager.source_id
     Index.drop_entry docid
     File.delete @source.fn_for_offset(entry[:source_info])
-    UpdateManager.relay self, :deleted, m
+    UpdateManager.relay self, :single_message_deleted, m
   end
 end
 
index aaa835509ed8db5a1adf87fb5424be35d9caae33..89dfec95ae12d066d542238e4852f0367fd490a4 100644 (file)
@@ -156,6 +156,14 @@ EOS
     BufferManager.draw_screen
   end
 
+  def handle_single_message_deleted_update sender, m
+    @ts_mutex.synchronize do
+      return unless @ts.contains? m
+      @ts.remove_id m.id
+    end
+    update
+  end
+
   def handle_deleted_update sender, m
     @ts_mutex.synchronize do
       return unless @ts.contains? m
index 4b36111924950c70f1ccea69654936180b5648a1..f54c935339c84841d22d59edb98fca7bd9da1457 100644 (file)
@@ -289,7 +289,16 @@ class ThreadSet
     remove_container c
     p.children << c
     c.parent = p
+    update_threading_for c
+  end
+  private :link
+
+  def remove_container c
+    c.parent.children.delete c if c.parent # remove from tree
+  end
+  private :remove_container
 
+  def update_threading_for c
     ## if the child was previously a top-level container, but now is not,
     ## ditch our thread and kill it if necessary
     if c.thread && !c.root?
@@ -298,17 +307,8 @@ class ThreadSet
       c.thread = nil
     end
   end
-  private :link
-
-  def remove_container c
-    c.parent.children.delete c if c.parent # remove from tree
-  end
-  private :remove_container
-
-  def prune_empty_threads; @threads.delete_if { |k, t| t.empty? } end
-  private :prune_empty_threads
+  private :update_threading_for
 
-  ## remove a single message id. not used anywhere, afaik.
   def remove_id mid
     return unless(c = @messages[mid])
     remove_container c