Sha256: 8f2af3957f3540b461af1b2ef69998d474bbcd9b298a583408cb8101a41475aa

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'thread'

module Redwood

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]
  end

  def killable?; false; end

  def archive
    remove_label_and_hide_thread cursor_thread, :inbox
    regen_text
  end

  def multi_archive threads
    threads.each { |t| remove_label_and_hide_thread t, :inbox }
    regen_text
  end

  def is_relevant? m; m.has_label? :inbox; end

  def load_more_threads n=ThreadIndexMode::LOAD_MORE_THREAD_NUM
    load_n_threads_background n, :label => :inbox,
                                 :load_killed => false,
                                 :load_spam => false,
                                 :when_done => lambda { |num|
      BufferManager.flash "Added #{num} threads."
    }
  end

  def reload
    drop_all_threads
    BufferManager.draw_screen
    load_more_threads buffer.content_height
  end
end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sup-0.0.3 lib/sup/modes/inbox-mode.rb