Sha256: 707a4f0769a2365d2185eb1273e1dff3d380aa7860df3a0cb8c23cde59105f60

Contents?: true

Size: 886 Bytes

Versions: 10

Compression:

Stored size: 886 Bytes

Contents

module Redwood

class ResumeMode < EditMessageMode
  def initialize m
    @m = m
    @safe = false

    header, body = parse_file m.draft_filename
    header.delete "Date"

    super :header => header, :body => body, :have_signature => true
  end

  def unsaved?; !@safe end

  def killable?
    return true if @safe

    case BufferManager.ask_yes_or_no "Discard draft?"
    when true
      DraftManager.discard @m
      BufferManager.flash "Draft discarded."
      true
    when false
      if edited?
        DraftManager.write_draft { |f| write_message f, false }
        DraftManager.discard @m
        BufferManager.flash "Draft saved."
      end
      true
    else
      false
    end
  end

  def send_message
    if super
      DraftManager.discard @m 
      @safe = true
    end
  end

  def save_as_draft
    @safe = true
    DraftManager.discard @m if super
  end
end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sup-0.12.1 lib/sup/modes/resume-mode.rb
sup-0.12 lib/sup/modes/resume-mode.rb
sup-0.11 lib/sup/modes/resume-mode.rb
sup-0.10.2 lib/sup/modes/resume-mode.rb
sup-0.10.1 lib/sup/modes/resume-mode.rb
sup-0.10 lib/sup/modes/resume-mode.rb
sup-0.9.1 lib/sup/modes/resume-mode.rb
sup-0.9 lib/sup/modes/resume-mode.rb
sup-0.8.1 lib/sup/modes/resume-mode.rb
sup-0.8 lib/sup/modes/resume-mode.rb