]> git.cworth.org Git - sup/blobdiff - lib/sup/poll.rb
maintain labels as Sets rather than arrays
[sup] / lib / sup / poll.rb
index 8a9d2188b7ec8f5f92e5bd44fc2beb94d475c282..0c46d2f4d1d3e67ddd33ad219857835963e293c3 100644 (file)
@@ -97,14 +97,14 @@ EOS
         numi = 0
         add_messages_from source do |m_old, m, offset|
           ## always preserve the labels on disk.
-          m.labels = ((m.labels - [:unread, :inbox]) + m_old.labels).uniq if m_old
-          yield "Found message at #{offset} with labels {#{m.labels * ', '}}"
+          m.labels = (m.labels - [:unread, :inbox]) + m_old.labels if m_old
+          yield "Found message at #{offset} with labels {#{m.labels.to_a * ', '}}"
           unless m_old
             num += 1
             from_and_subj << [m.from && m.from.longname, m.subj]
-            if m.has_label?(:inbox) && ([:spam, :deleted, :killed] & m.labels).empty?
+            if (m.labels & [:inbox, :spam, :deleted, :killed]) == Set.new([:inbox])
               from_and_subj_inbox << [m.from && m.from.longname, m.subj]
-              numi += 1 
+              numi += 1
             end
           end
           m