[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sup-devel] [PATCH] copy thread when spawning ThreadViewMode



Currently ThreadIndexMode just passes a reference to the selected thread when
spawning a ThreadViewMode. This is a problem because as long as the original
ThreadIndexMode is alive that thread will be updated with new messages, but
ThreadViewMode will not display them. This can lead to the user unknowingly
archiving a thread containing unread messages.
---
 lib/sup/modes/thread-index-mode.rb |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
index a6bb2b9..ca5e1f3 100644
--- a/lib/sup/modes/thread-index-mode.rb
+++ b/lib/sup/modes/thread-index-mode.rb
@@ -94,6 +94,18 @@ EOS
     load_threads :num => buffer.content_height
   end
 
+  def copy_thread t
+    ts = ThreadSet.new nil
+    t.each_with_index do |(m, *o), i|
+      next unless m
+      yield i
+      m.load_from_source!
+      ts.add_message m
+    end
+    fail unless ts.threads.size == 1
+    ts.threads.first
+  end
+
   ## open up a thread view window
   def select t=nil, when_done=nil
     t ||= cursor_thread or return
@@ -102,10 +114,8 @@ EOS
       num = t.size
       message = "Loading #{num.pluralize 'message body'}..."
       BufferManager.say(message) do |sid|
-        t.each_with_index do |(m, *o), i|
-          next unless m
+        t = copy_thread t do |i|
           BufferManager.say "#{message} (#{i}/#{num})", sid if t.size > 1
-          m.load_from_source! 
         end
       end
       mode = ThreadViewMode.new t, @hidden_labels, self
-- 
1.6.3.3

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel