From: wmorgan Date: Sun, 28 Oct 2007 17:38:45 +0000 (+0000) Subject: bugfix: label viewing and editing in thread-view-mode not quite right X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=4988359eb09ed23b19ab9ecf99560cf5c381dd76;p=sup bugfix: label viewing and editing in thread-view-mode not quite right git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@641 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- diff --git a/lib/sup/label.rb b/lib/sup/label.rb index ada1710..39a682a 100644 --- a/lib/sup/label.rb +++ b/lib/sup/label.rb @@ -5,12 +5,12 @@ class LabelManager ## labels that have special semantics. user will be unable to ## add/remove these via normal label mechanisms. - RESERVED_LABELS = [ :starred, :spam, :draft, :unread, :killed, :sent, :deleted ] + RESERVED_LABELS = [ :starred, :spam, :draft, :unread, :killed, :sent, :deleted, :inbox ] ## labels which it nonetheless makes sense to search for by - LISTABLE_RESERVED_LABELS = [ :starred, :spam, :draft, :sent, :killed, :deleted ] + LISTABLE_RESERVED_LABELS = [ :starred, :spam, :draft, :sent, :killed, :deleted, :inbox ] - ## labels that will never be displayed to the user + ## labels that will typically be hidden from the user HIDDEN_RESERVED_LABELS = [ :starred, :unread ] def initialize fn diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb index c40cf79..9c53242 100644 --- a/lib/sup/modes/thread-view-mode.rb +++ b/lib/sup/modes/thread-view-mode.rb @@ -140,10 +140,12 @@ class ThreadViewMode < LineCursorMode def edit_labels m = @message_lines[curpos] or return + + reserved_labels = m.labels.select { |l| LabelManager::RESERVED_LABELS.include? l } new_labels = BufferManager.ask_for_labels :label, "Labels for message: ", m.labels return unless new_labels - m.labels = new_labels + m.labels = (reserved_labels + new_labels).uniq new_labels.each { |l| LabelManager << l } ## TODO: don't recalculate EVERYTHING update @@ -441,11 +443,12 @@ private rest += format_person_list " Bcc: ", m.bcc end + show_labels = m.labels - LabelManager::HIDDEN_RESERVED_LABELS rest += [ " Date: #{m.date.strftime DATE_FORMAT} (#{m.date.to_nice_distance_s})", " Subject: #{m.subj}", (parent ? " In reply to: #{parent.from.mediumname}'s message of #{parent.date.strftime DATE_FORMAT}" : nil), - m.labels.empty? ? nil : " Labels: #{m.labels.join(', ')}", + show_labels.empty? ? nil : " Labels: #{show_labels.join(', ')}", ].compact from + rest.map { |l| [[color, prefix + " " + l]] }