lib/sup/poll.rb in sup-0.13.0 vs lib/sup/poll.rb in sup-0.13.1
- old
+ new
@@ -20,10 +20,12 @@
Executes immediately after a poll for new messages completes.
Variables:
num: the total number of new messages added in this poll
num_inbox: the number of new messages added in this poll which
appear in the inbox (i.e. were not auto-archived).
+ num_total: the total number of messages
+ num_inbox_total: the total number of new messages in the inbox.
num_inbox_total_unread: the total number of unread messages in the inbox
from_and_subj: an array of (from email address, subject) pairs
from_and_subj_inbox: an array of (from email address, subject) pairs for
only those messages appearing in the inbox
EOS
@@ -41,24 +43,37 @@
UpdateManager.register self
end
def poll_with_sources
@mode ||= PollMode.new
- HookManager.run "before-poll"
- BufferManager.flash "Polling for new messages..."
+ if HookManager.enabled? "before-poll"
+ HookManager.run("before-poll")
+ else
+ BufferManager.flash "Polling for new messages..."
+ end
+
num, numi, from_and_subj, from_and_subj_inbox, loaded_labels = @mode.poll
clear_running_totals if @should_clear_running_totals
@running_totals[:num] += num
@running_totals[:numi] += numi
@running_totals[:loaded_labels] += loaded_labels || []
- if @running_totals[:num] > 0
- BufferManager.flash "Loaded #{@running_totals[:num].pluralize 'new message'}, #{@running_totals[:numi]} to inbox. Labels: #{@running_totals[:loaded_labels].map{|l| l.to_s}.join(', ')}"
+
+
+ if HookManager.enabled? "after-poll"
+ hook_args = { :num => num, :num_inbox => numi,
+ :num_total => @running_totals[:num], :num_inbox_total => @running_totals[: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] } }
+
+ HookManager.run("after-poll", hook_args)
else
- BufferManager.flash "No new messages."
+ if @running_totals[:num] > 0
+ BufferManager.flash "Loaded #{@running_totals[:num].pluralize 'new message'}, #{@running_totals[:numi]} to inbox. Labels: #{@running_totals[:loaded_labels].map{|l| l.to_s}.join(', ')}"
+ else
+ BufferManager.flash "No new messages."
+ end
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] }
end
def poll
return if @polling