commit bb89f0a7d8ea9b375fb791908ad745b4d0355357
parent 9912422ac302bfeb6934fbe584bc010e520e8d52
Author: Whyme Lyu <callme5long@gmail.com>
Date: Fri, 24 May 2013 00:56:22 +0800
Handle unknown From account as customized
Diffstat:
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/sup/modes/edit_message_mode.rb b/lib/sup/modes/edit_message_mode.rb
@@ -131,13 +131,18 @@ EOS
HorizontalSelector.new "Account:", AccountManager.user_emails + [nil], user_emails_copy + ["Customized"]
if @header["From"] =~ /<?(\S+@(\S+?))>?$/
- @account_selector.set_to $1
- @account_user = ""
+ # TODO: this is ugly. might implement an AccountSelector and handle
+ # special cases more transparently.
+ account_from = @account_selector.can_set_to?($1) ? $1 : nil
+ @account_selector.set_to account_from
else
@account_selector.set_to nil
- @account_user = @header["From"]
end
+ # A single source of truth might better than duplicating this in both
+ # @account_user and @account_selector.
+ @account_user = @header["From"]
+
add_selector @account_selector
end