X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Fmodes%2Finbox-mode.rb;h=559892d5655f07b80a1186e114950156220a13c5;hb=e79b083fd8edcb88c169575ed5ff97c17f129023;hp=ae231a7097f7c9100fcaa9c12adf725d40cd5166;hpb=a7072d33045db9dc60cfebd7852b9e36970dd37b;p=sup diff --git a/lib/sup/modes/inbox-mode.rb b/lib/sup/modes/inbox-mode.rb index ae231a7..559892d 100644 --- a/lib/sup/modes/inbox-mode.rb +++ b/lib/sup/modes/inbox-mode.rb @@ -6,39 +6,68 @@ class InboxMode < ThreadIndexMode register_keymap do |k| ## overwrite toggle_archived with archive k.add :archive, "Archive thread (remove from inbox)", 'a' + k.add :read_and_archive, "Archive thread (remove from inbox) and mark read", 'A' end def initialize - super [:inbox], [:inbox] + super [:inbox, :sent, :draft], { :label => :inbox, :skip_killed => true } + raise "can't have more than one!" if defined? @@instance + @@instance = self end + def is_relevant? m + m.has_label?(:inbox) && ([:spam, :deleted, :killed] & m.labels).empty? + 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 status - super + " #{Index.size} messages in index" + def read_and_archive + return unless cursor_thread + cursor_thread.remove_label :unread + cursor_thread.remove_label :inbox + hide_thread cursor_thread + regen_text + end + + def multi_read_and_archive threads + threads.each do |t| + t.remove_label :unread + t.remove_label :inbox + hide_thread t + end + regen_text end - def is_relevant? m; m.has_label? :inbox; end + def handle_unarchived_update sender, m + add_or_unhide m + end - def load_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, m + t = thread_containing(m) or return + hide_thread t + regen_text + end + + def status + super + " #{Index.size} messages in index" end end