]> git.cworth.org Git - sup/blob - lib/sup/modes/inbox-mode.rb
fix my breaking of marcus's patch, thanks to marcus
[sup] / lib / sup / modes / inbox-mode.rb
1 require 'thread'
2
3 module Redwood
4
5 class InboxMode < ThreadIndexMode
6   register_keymap do |k|
7     ## overwrite toggle_archived with archive
8     k.add :archive, "Archive thread (remove from inbox)", 'a'
9   end
10
11   def initialize
12     super [:inbox, :sent], { :label => :inbox, :skip_killed => true }
13     raise "can't have more than one!" if defined? @@instance
14     @@instance = self
15   end
16
17   def is_relevant? m
18     m.has_label?(:inbox) && ([:spam, :deleted, :killed] & m.labels).empty?
19   end
20
21   ## label-list-mode wants to be able to raise us if the user selects
22   ## the "inbox" label, so we need to keep our singletonness around
23   def self.instance; @@instance; end
24   def killable?; false; end
25
26   def archive
27     return unless cursor_thread
28     cursor_thread.remove_label :inbox
29     hide_thread cursor_thread
30     regen_text
31   end
32
33   def multi_archive threads
34     threads.each do |t|
35       t.remove_label :inbox
36       hide_thread t
37     end
38     regen_text
39   end
40
41   def handle_archived_update sender, t
42     if contains_thread? t
43       hide_thread t
44       regen_text
45     end
46   end
47
48 # not quite working, and not sure if i like it anyways
49 #   def handle_unarchived_update sender, t
50 #     Redwood::log "unarchived #{t.subj}"
51 #     show_thread t
52 #   end
53
54   def status
55     super + "    #{Index.size} messages in index"
56   end
57 end
58
59 end