lib/sup/poll.rb in sup-0.9 vs lib/sup/poll.rb in sup-0.9.1

- old
+ new

@@ -43,13 +43,13 @@ @polling = true @mode ||= PollMode.new HookManager.run "before-poll" BufferManager.flash "Polling for new messages..." - num, numi, from_and_subj, from_and_subj_inbox = @mode.poll + num, numi, from_and_subj, from_and_subj_inbox, loaded_labels = @mode.poll if num > 0 - BufferManager.flash "Loaded #{num.pluralize 'new message'}, #{numi} to inbox." + BufferManager.flash "Loaded #{num.pluralize 'new message'}, #{numi} to inbox. Labels: #{loaded_labels.map{|l| l.to_s}.join(', ')}" else BufferManager.flash "No new messages." end HookManager.run "after-poll", :num => num, :num_inbox => numi, :from_and_subj => from_and_subj, :from_and_subj_inbox => from_and_subj_inbox, :num_inbox_total_unread => lambda { Index.num_results_for :labels => [:inbox, :unread] } @@ -74,10 +74,11 @@ def do_poll total_num = total_numi = 0 from_and_subj = [] from_and_subj_inbox = [] + loaded_labels = Set.new @mutex.synchronize do SourceManager.usual_sources.each do |source| # yield "source #{source} is done? #{source.done?} (cur_offset #{source.cur_offset} >= #{source.end_offset})" begin @@ -105,10 +106,11 @@ yield "Skipping already-imported message at #{m.source_info}" end else yield "Found new message at #{m.source_info} with labels #{m.labels.to_a * ','}" add_new_message m + loaded_labels.merge m.labels num += 1 from_and_subj << [m.from && m.from.longname, m.subj] if (m.labels & [:inbox, :spam, :deleted, :killed]) == Set.new([:inbox]) from_and_subj_inbox << [m.from && m.from.longname, m.subj] numi += 1 @@ -119,14 +121,15 @@ yield "Found #{num} messages, #{numi} to inbox." unless num == 0 total_num += num total_numi += numi end + loaded_labels = loaded_labels - LabelManager::HIDDEN_RESERVED_LABELS - [:inbox, :killed] yield "Done polling; loaded #{total_num} new messages total" @last_poll = Time.now @polling = false end - [total_num, total_numi, from_and_subj, from_and_subj_inbox] + [total_num, total_numi, from_and_subj, from_and_subj_inbox, loaded_labels] end ## like Source#each, but yields successive Message objects, which have their ## labels and offsets set correctly. ##