]> git.cworth.org Git - sup/blobdiff - lib/sup/modes/contact-list-mode.rb
abort message composition if the file is unedited
[sup] / lib / sup / modes / contact-list-mode.rb
index dc222073a0efb2c5c3de4ce850e41ca5040bdeab..6983aa0ced0b5e6a89b6d4aab41cbcdbfe1fd066 100644 (file)
@@ -23,7 +23,7 @@ class ContactListMode < LineCursorMode
     k.add :search, "Search for messages from particular people", 'S'
   end
 
-  def initialize mode = :regular
+  def initialize mode=:regular
     @mode = mode
     @tags = Tagger.new self
     @num = nil
@@ -35,7 +35,7 @@ class ContactListMode < LineCursorMode
   def alias
     p = @contacts[curpos] or return
     alias_contact p
-    regen_text
+    update
   end
 
   def lines; @text.length; end
@@ -50,7 +50,7 @@ class ContactListMode < LineCursorMode
 
   def multi_toggle_tagged threads
     @tags.drop_all_tags
-    regen_text
+    update
   end
 
   def apply_to_tagged; @tags.apply_to_tagged; end
@@ -58,7 +58,7 @@ class ContactListMode < LineCursorMode
   def load_more num=LOAD_MORE_CONTACTS_NUM
     @num += num
     load
-    regen_text
+    update
     BufferManager.flash "Added #{num} contacts."
   end
 
@@ -78,7 +78,7 @@ class ContactListMode < LineCursorMode
 
   def multi_search people
     mode = PersonSearchResultsMode.new people
-    BufferManager.spawn "personal search results", mode
+    BufferManager.spawn "search for #{people.map { |p| p.name }.join(', ')}", mode
     mode.load_threads :num => mode.buffer.content_height
   end
 
@@ -96,7 +96,7 @@ class ContactListMode < LineCursorMode
   def load_in_background
     Redwood::reporting_thread do
       load
-      regen_text
+      update
       BufferManager.draw_screen
     end
   end
@@ -113,9 +113,14 @@ class ContactListMode < LineCursorMode
   
 protected
 
+  def update
+    regen_text
+    buffer.mark_dirty if buffer
+  end
+
   def update_text_for_line line
     @text[line] = text_for_contact @contacts[line]
-    buffer.mark_dirty
+    buffer.mark_dirty if buffer
   end
 
   def text_for_contact p
@@ -127,13 +132,12 @@ protected
   def regen_text
     @awidth, @nwidth = 0, 0
     @contacts.each do |p|
-      aalias = ContactManager.alias_for_person(p)
+      aalias = ContactManager.alias_for(p)
       @awidth = aalias.length if aalias && aalias.length > @awidth
       @nwidth = p.name.length if p.name && p.name.length > @nwidth
     end
 
     @text = @contacts.map { |p| text_for_contact p }
-    buffer.mark_dirty
   end
 end