Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
From: Rich Lane <rlane@club.cc.cmu.edu>
To: sup-devel@rubyforge.org
Subject: [sup-devel] [PATCH] copy thread when spawning ThreadViewMode
Date: Thu, 21 Jan 2010 20:25:16 -0800	[thread overview]
Message-ID: <1264134316-17210-1-git-send-email-rlane@club.cc.cmu.edu> (raw)

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


             reply	other threads:[~2010-01-22  4:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-22  4:25 Rich Lane [this message]
2010-01-25 16:21 ` Rich Lane

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1264134316-17210-1-git-send-email-rlane@club.cc.cmu.edu \
    --to=rlane@club.cc.cmu.edu \
    --cc=sup-devel@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox