5 class InboxMode < ThreadIndexMode
7 ## overwrite toggle_archived with archive
8 k.add :archive, "Archive thread (remove from inbox)", 'a'
9 k.add :read_and_archive, "Archive thread (remove from inbox) and mark read", 'A'
13 super [:inbox, :sent, :draft], { :label => :inbox, :skip_killed => true }
14 raise "can't have more than one!" if defined? @@instance
19 m.has_label?(:inbox) && ([:spam, :deleted, :killed] & m.labels).empty?
22 ## label-list-mode wants to be able to raise us if the user selects
23 ## the "inbox" label, so we need to keep our singletonness around
24 def self.instance; @@instance; end
25 def killable?; false; end
28 return unless cursor_thread
29 thread = cursor_thread # to make sure lambda only knows about 'old' cursor_thread
32 thread.apply_label :inbox
33 add_or_unhide thread.first
35 UndoManager.register("archiving thread #{thread.first.id}", undo)
37 cursor_thread.remove_label :inbox
38 hide_thread cursor_thread
42 def multi_archive threads
43 undo = threads.map {|t|
48 UndoManager.register("archiving #{threads.size} #{threads.size.pluralize 'thread'}",
49 undo << lambda {regen_text} )
59 return unless cursor_thread
60 thread = cursor_thread # to make sure lambda only knows about 'old' cursor_thread
63 thread.apply_label :inbox
64 thread.apply_label :unread
65 add_or_unhide thread.first
67 UndoManager.register("reading and archiving thread ", undo)
69 cursor_thread.remove_label :unread
70 cursor_thread.remove_label :inbox
71 hide_thread cursor_thread
75 def multi_read_and_archive threads
76 undo = threads.map {|t|
83 UndoManager.register("reading and archiving #{threads.size} #{threads.size.pluralize 'thread'}",
84 undo << lambda {regen_text})
87 t.remove_label :unread
94 def handle_unarchived_update sender, m
98 def handle_archived_update sender, m
99 t = thread_containing(m) or return
105 super + " #{Index.size} messages in index"