sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 3cbccb471fc73b1593374ef8efea1a22ba237d89
parent f111201a469fd1c1dccb143e089cc623ce35025d
Author: Hamish Downer <dmishd@gmail.com>
Date:   Wed,  9 Feb 2011 18:58:30 +0000

Re-run the crypto selector hook after message changes.

The crypto-selector hook will be re-run after the message is edited,
or after the recipients change due to changing the "Reply to"
selector in reply-mode. So when the recipients change, the default
selector will also change.

However, if the user has manually changed the crypto selector then the
hook will not be re-run, so as to avoid over-riding the user's choice.

Diffstat:
M lib/sup/modes/edit-message-mode.rb | 7 +++++++
M lib/sup/modes/reply-mode.rb | 2 ++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
@@ -179,6 +179,7 @@ EOS
     header, @body = parse_file @file.path
     @header = header - NON_EDITABLE_HEADERS
     handle_new_text @header, @body
+    rerun_crypto_selector_hook
     update
 
     @edited
@@ -215,6 +216,12 @@ EOS
 
 protected
 
+  def rerun_crypto_selector_hook
+    if @crypto_selector && !@crypto_selector.changed_by_user
+      HookManager.run "crypto-mode", :header => @header, :body => @body, :crypto_selector => @crypto_selector
+    end
+  end
+
   def mime_encode string
     string = [string].pack('M') # basic quoted-printable
     string.gsub!(/=\n/,'')      # .. remove trailing newline
diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb
@@ -165,6 +165,7 @@ protected
     if @headers[@type_selector.val] != self.header
       self.header = @headers[@type_selector.val]
       self.body = @bodies[@type_selector.val] unless @edited
+      rerun_crypto_selector_hook
       update
     end
   end
@@ -174,6 +175,7 @@ protected
     if @headers[@type_selector.val] != self.header
       self.header = @headers[@type_selector.val]
       self.body = @bodies[@type_selector.val] unless @edited
+      rerun_crypto_selector_hook
       update
     end
   end