]> git.cworth.org Git - sup/blob - lib/sup/modes/inbox-mode.rb
final (?) 0.0.7 updates
[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], [:inbox]
13   end
14
15   def killable?; false; end
16
17   def archive
18     cursor_thread.remove_label :inbox
19     hide_thread cursor_thread
20     regen_text
21   end
22
23   def multi_archive threads
24     threads.each { |t| remove_label_and_hide_thread t, :inbox }
25     regen_text
26   end
27
28   def handle_archived_update sender, t
29     hide_thread t if contains_thread? t
30   end
31
32 # not quite working, and not sure if i like it anyways
33 #   def handle_unarchived_update sender, t
34 #     Redwood::log "unarchived #{t.subj}"
35 #     show_thread t
36 #   end
37
38   def status
39     super + "    #{Index.size} messages in index"
40   end
41
42   def is_relevant? m; m.has_label? :inbox; end
43
44   def load_threads opts={}
45     n = opts[:num] || ThreadIndexMode::LOAD_MORE_THREAD_NUM
46     load_n_threads_background n, :label => :inbox,
47                                  :when_done => (lambda do |num|
48       opts[:when_done].call if opts[:when_done]
49       BufferManager.flash "Added #{num} threads."
50     end)
51   end
52 end
53
54 end