]> git.cworth.org Git - sup/blobdiff - lib/sup/modes/label-list-mode.rb
Merge branch 'xapian-updates'
[sup] / lib / sup / modes / label-list-mode.rb
index a35d110df8d0607589b9c412682818674c181c9c..f65ec2e2080f2f823b1fa102fb77d2cc5f4cbae5 100644 (file)
@@ -65,8 +65,15 @@ protected
 
     @labels = []
     counts.map do |label, string, total, unread|
-      if total == 0 && !LabelManager::RESERVED_LABELS.include?(label)
-        Redwood::log "no hits for label #{label}, deleting"
+      ## if we've done a search and there are no messages for this label, we can delete it from the
+      ## list. BUT if it's a brand-new label, the user may not have sync'ed it to the index yet, so
+      ## don't delete it in this case.
+      ##
+      ## this is all a hack. what should happen is:
+      ##   TODO make the labelmanager responsible for label counts
+      ## and then it can listen to labeled and unlabeled events, etc.
+      if total == 0 && !LabelManager::RESERVED_LABELS.include?(label) && !LabelManager.new_label?(label)
+        debug "no hits for label #{label}, deleting"
         LabelManager.delete label
         next
       end