]> git.cworth.org Git - sup/blobdiff - lib/sup/modes/compose-mode.rb
finally, attachment support\!
[sup] / lib / sup / modes / compose-mode.rb
index 677d9995a6f8cf6f19f8600eb297071c74259440..fe7127956918dfd4154d48c67f5370b8705f2750 100644 (file)
@@ -1,36 +1,17 @@
 module Redwood
 
 class ComposeMode < EditMessageMode
-  attr_reader :body, :header
-
   def initialize opts={}
-    super()
-    @header = {
+    header = {
       "From" => AccountManager.default_account.full_address,
-      "Message-Id" => gen_message_id,
     }
 
-    @header["To"] = opts[:to].map { |p| p.full_address }.join(", ") if opts[:to]
-    @header["Cc"] = opts[:cc].map { |p| p.full_address }.join(", ") if opts[:cc]
-    @header["Bcc"] = opts[:bcc].map { |p| p.full_address }.join(", ") if opts[:bcc]
-    @header["Subject"] = opts[:subj] if opts[:subj]
-
-    @body = opts[:body] || sig_lines
-    regen_text
-  end
-
-  def lines; @text.length; end
-  def [] i; @text[i]; end
-
-protected
-
-  def handle_new_text new_header, new_body
-    @header = new_header
-    @body = new_body
-  end
+    header["To"] = opts[:to].map { |p| p.full_address }.join(", ") if opts[:to]
+    header["Cc"] = opts[:cc].map { |p| p.full_address }.join(", ") if opts[:cc]
+    header["Bcc"] = opts[:bcc].map { |p| p.full_address }.join(", ") if opts[:bcc]
+    header["Subject"] = opts[:subj] if opts[:subj]
 
-  def regen_text
-    @text = header_lines(@header - EditMessageMode::NON_EDITABLE_HEADERS) + [""] + @body
+    super :header => header, :body => (opts[:body] || [])
   end
 end