]> git.cworth.org Git - sup/blobdiff - lib/sup/modes/inbox-mode.rb
use default account values for name, sendmail, signature account fields, and properly...
[sup] / lib / sup / modes / inbox-mode.rb
index b4da4f60f4488c4649967a174ec3f51d7b9cba49..23da9795b438db83912ee943ff750d7e7f992997 100644 (file)
@@ -6,43 +6,51 @@ class InboxMode < ThreadIndexMode
   register_keymap do |k|
     ## overwrite toggle_archived with archive
     k.add :archive, "Archive thread (remove from inbox)", 'a'
-    k.add :load_more_threads, "Load #{LOAD_MORE_THREAD_NUM} more threads", 'M'
-    k.add :reload, "Discard threads and reload", 'D'
   end
 
   def initialize
-    super [:inbox], [:inbox]
+    super [:inbox, :sent], { :label => :inbox }
+    raise "can't have more than one!" if defined? @@instance
+    @@instance = self
   end
 
+  def is_relevant? m; m.has_label? :inbox; end
+
+  ## label-list-mode wants to be able to raise us if the user selects
+  ## the "inbox" label, so we need to keep our singletonness around
+  def self.instance; @@instance; end
   def killable?; false; end
 
   def archive
-    remove_label_and_hide_thread cursor_thread, :inbox
+    return unless cursor_thread
+    cursor_thread.remove_label :inbox
+    hide_thread cursor_thread
     regen_text
   end
 
   def multi_archive threads
-    threads.each { |t| remove_label_and_hide_thread t, :inbox }
+    threads.each do |t|
+      t.remove_label :inbox
+      hide_thread t
+    end
     regen_text
   end
 
-  def is_relevant? m; m.has_label? :inbox; end
-
-  def load_more_threads opts={}
-    n = opts[:num] || ThreadIndexMode::LOAD_MORE_THREAD_NUM
-    load_n_threads_background n, :label => :inbox,
-                                 :load_killed => false,
-                                 :load_spam => false,
-                                 :when_done => (lambda do |num|
-      opts[:when_done].call if opts[:when_done]
-      BufferManager.flash "Added #{num} threads."
-    end)
+  def handle_archived_update sender, t
+    if contains_thread? t
+      hide_thread t
+      regen_text
+    end
   end
 
-  def reload
-    drop_all_threads
-    BufferManager.draw_screen
-    load_more_threads :num => buffer.content_height
+# not quite working, and not sure if i like it anyways
+#   def handle_unarchived_update sender, t
+#     Redwood::log "unarchived #{t.subj}"
+#     show_thread t
+#   end
+
+  def status
+    super + "    #{Index.size} messages in index"
   end
 end