]> git.notmuchmail.org Git - sup/commitdiff
fixed loading bug (messages now loaded completely before tehread-view-mode gets them...
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 22 Jan 2007 01:21:27 +0000 (01:21 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 22 Jan 2007 01:21:27 +0000 (01:21 +0000)
threads also now cloned before passing to thread=-view-mode
this should fix some bugs that occur when messages are added to a thread after thread-view-mode has started laying them out
goddamn this connection sucks and i don't want to fix my typos

git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@272 5c8cc53c-5e98-4d25-b20a-d8db53a31250

doc/TODO
lib/sup/message.rb
lib/sup/modes/thread-index-mode.rb
lib/sup/modes/thread-view-mode.rb

index 47dfd95bb5a62950379180d99136f51f2fca8267..2aea3380d7a3634ee42a0ec29e0431b5f85dbf59 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -1,7 +1,5 @@
 de-archived messages should be auto-added to inbox
 drafts sometimes not loaded
-bugfix: first time viewing a message only gets the first to:;
-   subsequent views get them all (wtf)
 add a flag to sup-import to force the creation of a new source (see http://rubyforge.org/forum/forum.php?thread_id=10973&forum_id=10340)
 fix bug: when returning from a shelling out, ncurses is crazy 
 batch deletion
@@ -25,6 +23,7 @@ move sup-import argument handling to getopt
 be able to mark individual messages as spam in thread-view-mode
 toggle wrapping
 
+x bugfix: first time viewing a message only gets the first to:; subsequent views get them all (wtf)
 x search for other messages from author in thread-view-mode
 x resuming of arbitrary messages
 x alias authors in thread-view-mode
index 9a6b2ccba0dad862cfa77f161567ecc32537dab4..4e7d3caf2ca4f3a1b1ace829b3805c2f995356a4 100644 (file)
@@ -46,6 +46,7 @@ class Message
 
       ## TODO: handle unknown mime-types
       system "/usr/bin/run-mailcap --action=view #{@content_type}:#{@file.path}"
+      $? == 0
     end
 
     def to_s; @part.decode; end
@@ -83,7 +84,7 @@ class Message
 
   attr_reader :id, :date, :from, :subj, :refs, :replytos, :to, :source,
               :cc, :bcc, :labels, :list_address, :recipient_email, :replyto,
-              :source_info
+              :source_info, :chunks
 
   bool_reader :dirty, :source_marked_read
 
@@ -96,8 +97,11 @@ class Message
     @have_snippet = !opts[:snippet].nil?
     @labels = opts[:labels] || []
     @dirty = false
+    @chunks = nil
 
-    read_header(opts[:header] || @source.load_header(@source_info))
+    raise ArgumentError, "need a header" unless opts[:header]
+    read_header opts[:header]
+    #read_header(opts[:header] || @source.load_header(@source_info))
   end
 
   def read_header header
@@ -173,7 +177,7 @@ class Message
   end
 
   ## this is called when the message body needs to actually be loaded.
-  def chunks
+  def load_from_source!
     @chunks ||=
       if @source.broken?
         [Text.new(error_message(@source.broken_msg.split("\n")))]
@@ -185,6 +189,8 @@ class Message
           ## i could just store that in the index, but i think there might
           ## be other things like that in the future, and i'd rather not
           ## bloat the index.
+          ## actually, it's also the differentiation between to/cc/bcc,
+          ## so i will keep this.
           read_header @source.load_header(@source_info)
           message_to_chunks @source.load_message(@source_info)
         rescue SourceError, SocketError, MessageFormatError => e
index c6baa531933e236bd151aeff24b23c9031854bc3..b474a09c20b74057a3b1bf5f2c5f1820280f7106 100644 (file)
@@ -56,8 +56,13 @@ class ThreadIndexMode < LineCursorMode
   def select t=nil
     t ||= @threads[curpos]
 
+    t = t.clone # XXXX highly experimental
+
     ## TODO: don't regen text completely
     Redwood::reporting_thread do
+      BufferManager.say("Loading message bodies...") do |sid|
+        t.each { |m, *o| m.load_from_source! }
+      end
       mode = ThreadViewMode.new t, @hidden_labels
       BufferManager.spawn t.subj, mode
       BufferManager.draw_screen
index 2549a1fe09c3a01f348e7c831628a181c008b872..897f863d73b0e52771d73102d7a06800a85890ef 100644 (file)
@@ -61,7 +61,7 @@ class ThreadViewMode < LineCursorMode
     @layout[latest].state = :open if @layout[latest].state == :closed
     @layout[earliest].state = :detailed if earliest.has_label?(:unread) || @thread.size == 1
 
-    BufferManager.say("Loading message bodies...") { update }
+    regen_text
   end
 
   def draw_line ln, opts={}
@@ -287,23 +287,6 @@ private
         @text += chunk_to_lines m, nil, @text.length, depth, parent
         next
       end
-
-      ## we're occasionally called on @threads that have had messages
-      ## added to them since initialization. luckily we regen_text on
-      ## the entire thread every time the user does anything besides
-      ## scrolling (basically), so we can just slap this on here.
-      ##
-      ## to pick nits, the niceness that i do in the constructor with
-      ## 'latest' etc. (for automatically opening just the latest
-      ## message if everything's been read) will not be valid, but
-      ## that's just a nicety and hopefully this won't happen too
-      ## often.
-
-      unless @layout.member? m
-        l = @layout[m] = Layout.new
-        l.state = initial_state_for m
-        l.color = prevm && @layout[prevm].color == :message_patina_color ? :alternate_patina_color : :message_patina_color
-      end
       l = @layout[m]
 
       ## build the patina
@@ -456,9 +439,10 @@ private
 
   def view_attachment a
     BufferManager.flash "viewing #{a.content_type} attachment..."
-    a.view!
+    success = a.view!
     BufferManager.erase_flash
     BufferManager.completely_redraw_screen
+    BufferManager.flash "Couldn't execute view command." unless success
   end
 
 end