lib/mournmail/summary_mode.rb in mournmail-1.0.4 vs lib/mournmail/summary_mode.rb in mournmail-1.0.5
- old
+ new
@@ -476,10 +476,15 @@
mournmail
end
private
+ def get_summary_item(uid)
+ summary = Mournmail.current_summary
+ summary && summary[uid]
+ end
+
def selected_uid
uid = @buffer.save_excursion {
@buffer.beginning_of_line
if !@buffer.looking_at?(/ *\d+/)
Mournmail.current_mail = nil
@@ -536,20 +541,20 @@
window = Mournmail.message_window
window.buffer = message_buffer
end
def mark_as_seen(uid, update_server)
- summary_item = Mournmail.current_summary[uid]
+ summary_item = get_summary_item(uid)
if summary_item && !summary_item.flags.include?(:Seen)
summary_item.set_flag(:Seen, update_server: update_server)
Mournmail.current_summary.save
update_flags(summary_item)
end
end
def toggle_flag(uid, flag)
- summary_item = Mournmail.current_summary[uid]
+ summary_item = get_summary_item(uid)
if summary_item
Mournmail.background do
summary_item.toggle_flag(flag)
Mournmail.current_summary.save
foreground do
@@ -594,12 +599,12 @@
def show_search_result(messages,
query: nil, buffer_name: "*search result*")
summary_text = messages.map { |m|
format("%s [ %s ] %s\n",
m.date.strftime("%m/%d %H:%M"),
- ljust(m.from.to_s, 16),
- ljust(m.subject.to_s, 45))
+ ljust(m.from.to_s.gsub(/\n/, ""), 16),
+ ljust(m.subject.to_s.gsub(/\n/, ""), 45))
}.join
buffer = Buffer.find_or_new(buffer_name, undo_limit: 0,
read_only: true)
buffer.apply_mode(Mournmail::SearchResultMode)
buffer.read_only_edit do
@@ -655,10 +660,10 @@
end
end
def current_message
uid = selected_uid
- item = Mournmail.current_summary[uid]
+ item = get_summary_item(uid)
message = Groonga["Messages"][item.cache_id]
if message.nil?
raise EditorError, "No message found"
end
message